| Package Data | |
|---|---|
| Maintainer Username: | skrajewski |
| Maintainer Contact: | szykra@gmail.com (Szymon Krajewski) |
| Package Create Date: | 2014-07-10 |
| Package Last Update: | 2016-01-22 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-30 03:07:31 |
| Package Statistics | |
|---|---|
| Total Downloads: | 38,280 |
| Monthly Downloads: | 39 |
| Daily Downloads: | 3 |
| Total Stars: | 8 |
| Total Watchers: | 3 |
| Total Forks: | 3 |
| Total Open Issues: | 0 |
Flash Notifications Helper for Laravel 5
Add dependency to your composer.json file and run composer update.
require: {
"szykra/laravel-flash-notifications": "~0.3"
}
Add ServiceProvider and Alias (Facade) to your config/app.php file:
'Szykra\Notifications\NotificationServiceProvider'
'Flash' => 'Szykra\Notifications\Flash'
Package default provides bootstrap ready alert view. Just include notifications::flash file to your main layout in blade:
@include('notifications::flash')
You can create own container for flash notifications with own custom styles. See Custom alert view section.
You can push flash message ever you need by facade Flash. It provides 4 alert types:
Flash::info('Your alert message here!');
~~Method push() exists because you can push more than one alert at the same time. See below.~~
Every alert method takes 1 or 2 arguments. If you give one parameter it will be message. If you provide two parameters, first will be title and second will be message.
Flash::success('User has been updated successfully.');
Flash::error('Oh snap!', 'Something went wrong. Please try again for a few seconds.');
Package default provides bootstrap ready view for alerts. You can define own style for it. Just create new blade template file!
@if(Session::has('flash.alerts'))
@foreach(Session::get('flash.alerts') as $alert)
<div class='alert alert-{{ $alert['level'] }}'>
<button class="close" type="button" data-dismiss="alert" aria-hidden="true">×</button>
@if( ! empty($alert['title']))
<div><strong>{{ $alert['title'] }}</strong></div>
@endif
{{ $alert['message'] }}
</div>
@endforeach
@endif
All alerts will be in flash.alerts session variable. Single alert looks like:
[
'title' => 'Title',
'message' => 'Example message',
'level' => 'success'
]
Level for all alerts are following:
Flash::success has level success
Flash::error has level danger
Flash::warning has level warning
Flash::info has level info
The MIT License. Copyright (c) 2014 - 2015 Szymon Krajewski.