PHPackages                             besrabasant/laravel-flash - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. besrabasant/laravel-flash

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

besrabasant/laravel-flash
=========================

Easy flash notifications

06PHP

Since Oct 28Pushed 4y agoCompare

[ Source](https://github.com/besrabasant/laravel-flash)[ Packagist](https://packagist.org/packages/besrabasant/laravel-flash)[ RSS](/packages/besrabasant-laravel-flash/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Easy Flash Alert and Toast Messages for Your Laravel App
========================================================

[](#easy-flash-alert-and-toast-messages-for-your-laravel-app)

This composer package offers a Twitter Bootstrap optimized flash messaging setup for your Laravel applications.

Installation
------------

[](#installation)

Begin by pulling in the package through Composer.

```
composer require besrabasant/laravel-flash
```

Next, as noted above, the default CSS classes for your flash message are optimized for Bootstrap. So you need to include the styles and scripts.

Usage
-----

[](#usage)

Within your controllers, before you perform a redirect, make a call to the `alert()` or `toast()` function.

```
public function store()
{
    alert('Welcome Aboard!');

    return home();
}
```

or

```
public function store()
{
    toast('Task completed successfully!');

    return home();
}
```

For Alert Notifications You may also do:

- `alert('Message')->success()`: Set the alert theme to "success".
- `alert('Message')->error()`: Set the alert theme to "danger".
- `alert('Message')->warning()`: Set the alert theme to "warning".
- `alert('Message')->overlay()`: Render the message as an overlay.
- `alert()->overlay('Modal Message', 'Modal Title')`: Display a modal overlay with a title.
- `alert('Message')->important()`: Add a close button to the alert message.
- `alert('Message')->error()->important()`: Render a "danger" alert message that must be dismissed.

With this message flashed to the session, you may now display it in your view(s). Because flash messages and overlays are so common, we provide a template out of the box to get you started. You're free to use - and even modify to your needs - this template how you see fit.

For Toast Notifications You may also do:

- `toast('Message')->success()`: Set the toast theme to "success".
- `toast('Message')->error()`: Set the toast theme to "danger".
- `toast('Message')->warning()`: Set the toast theme to "warning".
- `toast('Message')->important()`: Add a close button to the toast message.
- `toast('Message')->error()->important()`: Render a "danger" toast message that must be dismissed.

```
@include('alert::messages')
```

```
@include('toast::container')
```

Example
-------

[](#example)

```
>

    Document

    @include('alert::messages')

    Welcome to my website...

    @include('toast::container')

    var lnAlertModal = bootstrap.Modal.getOrCreateInstance(document.getElementById('laravel_notifications__alert-overlay-modal'))
    lnAlertModal.show();

```

If you need to modify the alert message partials, you can run:

```
php artisan vendor:publish --provider="Laracasts\Flash\FlashServiceProvider"
```

The two package views will now be located in the `resources/views/vendor/alert/` directory.

```
alert('Welcome Aboard!');

return home();
```

[![https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/message.png](https://camo.githubusercontent.com/ea8b3221a5ac8f1dd24ce31888dfb406fb500576b08f27cdd947f0f363e0eaad/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f3737343835392f4769744875622d5265706f732f666c6173682f6d6573736167652e706e67)](https://camo.githubusercontent.com/ea8b3221a5ac8f1dd24ce31888dfb406fb500576b08f27cdd947f0f363e0eaad/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f3737343835392f4769744875622d5265706f732f666c6173682f6d6573736167652e706e67)

```
alert('Sorry! Please try again.')->error();

return home();
```

[![https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/error.png](https://camo.githubusercontent.com/f772165d97c60686d8bc5279dde14eebb2e570d333f4721b975928bf722405ba/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f3737343835392f4769744875622d5265706f732f666c6173682f6572726f722e706e67)](https://camo.githubusercontent.com/f772165d97c60686d8bc5279dde14eebb2e570d333f4721b975928bf722405ba/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f3737343835392f4769744875622d5265706f732f666c6173682f6572726f722e706e67)

```
alert()->overlay('You are now a Laracasts member!', 'Yay');

return home();
```

[![https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/overlay.png](https://camo.githubusercontent.com/97b6fa964c2ff2a81eb3142d61137101cfe4bdb6f6dcbde8c094e604b451b540/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f3737343835392f4769744875622d5265706f732f666c6173682f6f7665726c61792e706e67)](https://camo.githubusercontent.com/97b6fa964c2ff2a81eb3142d61137101cfe4bdb6f6dcbde8c094e604b451b540/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f3737343835392f4769744875622d5265706f732f666c6173682f6f7665726c61792e706e67)

> [Learn exactly how to build this very package on Laracasts!](https://laracasts.com/lessons/flexible-flash-messages)

Hiding Flash Messages
---------------------

[](#hiding-flash-messages)

A common desire is to display a flash message for a few seconds, and then hide it. To handle this, write a simple bit of JavaScript. For example, using jQuery, you might add the following snippet just before the closing `` tag.

```

    $('div.alert').not('.alert-important').delay(3000).fadeOut(350);

```

This will find any alerts - excluding the important ones, which should remain until manually closed by the user - wait three seconds, and then fade them out.

Multiple Flash Messages
-----------------------

[](#multiple-flash-messages)

Need to flash multiple flash messages to the session? No problem.

```
alert('Message 1');
alert('Message 2')->important();

return redirect('somewhere');
```

Done! You'll now see two flash messages upon redirect.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/dad82b75673f92870be4e40894f7f60b40e4f0ceaa2ad79a5c7d76802a3320cc?d=identicon)[besrabasant](/maintainers/besrabasant)

---

Top Contributors

[![JeffreyWay](https://avatars.githubusercontent.com/u/183223?v=4)](https://github.com/JeffreyWay "JeffreyWay (59 commits)")[![shaneparsons](https://avatars.githubusercontent.com/u/5495493?v=4)](https://github.com/shaneparsons "shaneparsons (3 commits)")[![besrabasant](https://avatars.githubusercontent.com/u/13284206?v=4)](https://github.com/besrabasant "besrabasant (3 commits)")[![zablose](https://avatars.githubusercontent.com/u/8734335?v=4)](https://github.com/zablose "zablose (2 commits)")[![chaot1xMD](https://avatars.githubusercontent.com/u/36856151?v=4)](https://github.com/chaot1xMD "chaot1xMD (2 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (2 commits)")[![jpuck](https://avatars.githubusercontent.com/u/15305396?v=4)](https://github.com/jpuck "jpuck (2 commits)")[![LordMilutin](https://avatars.githubusercontent.com/u/76582100?v=4)](https://github.com/LordMilutin "LordMilutin (2 commits)")[![quickliketurtle](https://avatars.githubusercontent.com/u/1762128?v=4)](https://github.com/quickliketurtle "quickliketurtle (2 commits)")[![imknight](https://avatars.githubusercontent.com/u/77604?v=4)](https://github.com/imknight "imknight (1 commits)")[![dbpolito](https://avatars.githubusercontent.com/u/347400?v=4)](https://github.com/dbpolito "dbpolito (1 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (1 commits)")[![kezadias](https://avatars.githubusercontent.com/u/5727111?v=4)](https://github.com/kezadias "kezadias (1 commits)")[![landrok](https://avatars.githubusercontent.com/u/3310446?v=4)](https://github.com/landrok "landrok (1 commits)")[![waiyan112](https://avatars.githubusercontent.com/u/3263761?v=4)](https://github.com/waiyan112 "waiyan112 (1 commits)")[![markwalet](https://avatars.githubusercontent.com/u/11446771?v=4)](https://github.com/markwalet "markwalet (1 commits)")[![MarnuLombard](https://avatars.githubusercontent.com/u/2191786?v=4)](https://github.com/MarnuLombard "MarnuLombard (1 commits)")[![minkbear](https://avatars.githubusercontent.com/u/233714?v=4)](https://github.com/minkbear "minkbear (1 commits)")[![NathanGiesbrecht](https://avatars.githubusercontent.com/u/1516627?v=4)](https://github.com/NathanGiesbrecht "NathanGiesbrecht (1 commits)")[![andrewturner](https://avatars.githubusercontent.com/u/60941?v=4)](https://github.com/andrewturner "andrewturner (1 commits)")

### Embed Badge

![Health badge](/badges/besrabasant-laravel-flash/health.svg)

```
[![Health](https://phpackages.com/badges/besrabasant-laravel-flash/health.svg)](https://phpackages.com/packages/besrabasant-laravel-flash)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
