Package Data | |
---|---|
Maintainer Username: | akaamitgupta |
Maintainer Contact: | akaamitgupta@gmail.com (Amit Gupta) |
Package Create Date: | 2016-09-19 |
Package Last Update: | 2016-10-06 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-14 15:15:07 |
Package Statistics | |
---|---|
Total Downloads: | 4,896 |
Monthly Downloads: | 5 |
Daily Downloads: | 0 |
Total Stars: | 14 |
Total Watchers: | 4 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Laravel 5 flash messages, originally developed after the Laracasts video tutorial on the same topic: Flexible Flash Messages.
$ composer require squareboat/flash
Once installation operation is complete, simply add both the service provider and facade classes to your project's config/app.php
file:
SquareBoat\Flash\FlashServiceProvider::class,
'Flash' => SquareBoat\Flash\Facades\Flash::class,
Package default provides bootstrap ready alert view. Just include flash::message
file to your main layout in blade:
@include('flash::message')
or if you don't use blade:
<?= view('flash::message') ?>
If you need to modify the flash message partials, you can run:
php artisan vendor:publish
The package view will now be located in the resources/views/vendor/flash
directory.
And that's it! With your coffee in reach, start flashing out messages!
Within your controllers, before you perform a redirect...
public function create()
{
// do something awesome...
flash()->success('Resource created successfully!');
return redirect()->route('dashboard');
}
Success
Flash::success('This is a success message.');
or
flash()->success('This is a success message.');
Info
Flash::info('This is an info message.');
or
flash()->info('This is an info message.');
Warning
Flash::warning('This is a warning message.');
or
flash()->warning('This is a warning message.');
Error
Flash::error('This is an error message.');
or
flash()->error('This is an error message.');
Important
Flash::info('This is an important message.')->important();
or
flash('This is an important message.')->important();
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.
<script>
$('div.alert').not('.alert-important').delay(3000).fadeOut(350);
</script>
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.
The MIT License. Please see License File for more information. Copyright © 2016 SquareBoat