Skip to content

Sweetalert and Toaster notifications for Laravel livewire

Notifications You must be signed in to change notification settings

simtabi/laratoast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laratoast

Integrate livewire with sweetalert.

composer require simtabi/laratoast

How to use

1. Add LaratoastServiceProvider in config/app.php

    ...
    Simtabi\Laratoast\LaratoastServiceProvider::class
    ...

2. Include javascript

    ...
    // place this directive in the header
    @laratoastCss

    // no need to call this, as it has already been called when you call @laratoastScripts
    @laratoastInit
    ...

3. Extra config file

Publish the configs: php artisan vendor:publish --tag=laratoast:assets. Publish the configs: php artisan vendor:publish --tag=laratoast:config. Publish the configs: php artisan vendor:publish --tag=laratoast:views.

See available configuration


Building toasts and sweetalerts

To make it easy to build toasts and sweetalerts, we have implemented chained methods to help you with building

Sweetalert

In your component add Toast trait. Then call toast method whenever you want.

use Simtabi\Laratoast\HasLaratoasts;
use Livewire\Component;

class MyComponent extends Component
{
    use HasLaratoasts;

    public function save() {
        $this->fireSweetalertModal();
    }

}

sweetalert parameters:

  • title
  • icon: success, error, warning, info, question - default is info
  • timeout: in milliseconds, default is 5000

Toast

This is the normal sweetalert modal. In your component add Fire trait. Then call fire method whenever you want.

use Simtabi\Laratoast\HasLaratoasts;
use Livewire\Component;

class MyComponent extends Component
{
    use HasLaratoasts;

    public function save() {
        $this->fireToastNotification();
    }

}

toast parameters:

Refer to the documentation online at: https://github.com/kamranahmedse/jquery-toast-plugin


Available configuration

About

Sweetalert and Toaster notifications for Laravel livewire

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published