Download the PHP package standaniels/flash without Composer
On this page you can find all versions of the php package standaniels/flash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package flash
Easy Flash Messages for Your Laravel App
Forked from laracasts/flash to add support for multiple notifications.
Installation
First, pull in the package through Composer.
Run composer require standaniels/flash
And then, if using Laravel 5, include the service provider within config/app.php
.
Usage
Within your controllers, before you perform a redirect...
You may also do:
flash('Message', 'info')
flash('Message', 'success')
flash('Message', 'danger')
flash('Message', 'warning')
flash()->overlay('Modal Message', 'Modal Title')
flash('Message')->important()
Behind the scenes, this will set a flash_notifications
key which contains an array of messages. Every messages is an instance of Illuminate\Support\Collection
:
- 'message' - The message you're flashing
- 'level' - A string that represents the type of notification (good for applying HTML class names)
With this message flashed to the session, you may now display it in your view(s). Maybe something like:
Note that this package is optimized for use with Twitter Bootstrap.
Because flash messages and overlays are so common, if you want, you may use (or modify) the views that are included with this package. Simply append to your layout view:
Example
If you need to modify the flash message partials, you can run:
The two package views will now be located in the app/views/packages/standaniels/flash/
directory.
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 </body>
tag.
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.
Credits
Special thanks to Jeffrey Way's laracasts/flash.