Sweet Alert flash notifications in Laravel.

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 4 521

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 2

Open Issues: 0


v1.0.1 2019-04-05 15:13 UTC

This package is auto-updated.

Last update: 2024-04-06 01:35:44 UTC



Note: This installation assumes you've already included Sweet Alert in your html layout.

Require flash in your composer.json file:

"stevebauman/flash": "1.0.*",

Then run composer update.

Now create a partial blade file (maybe resources/views/_flash.blade.php?), and insert the following:

    <script type="text/javascript">
            title: "{!! session('flash_message.title') !!}",
            text: "{!! session('flash_message.message') !!}",
            type: "{!! session('flash_message.level') !!}",
            @if(session('flash_message.timer')) timer: "{!! session('flash_message.timer') !!}" @endif

Your all set!


Call the flash() helper method like so:

flash()->create($title = 'Custom', $message = 'Message Content', $level = 'info');

flash()->success('Success!', "You've successfully done something, congrats!");

flash()->info('Info!', "Just letting you know something informative.");

flash()->warning('Warning!', 'Hey watch out, somethings going on!');

flash()->error('Error!', "Uh oh, there was an error doing something!");

Setting an automatic timeout of the notification:

Note, by default notifications have a 2 second timeout.

flash()->setTimer(5000)->success('Success!', 'This notification will disappear in five seconds.');