dev-master
9999999-devPackage for sending alerts with Laravel 5.
MIT
The Requires
The Development Requires
by Derek J. Augustine
laravel alerts
Wallogit.com
2017 © Pedro Peláez
Package for sending alerts with Laravel 5.
This package is in very early initial development, things are very likely going change before a stable release is tagged., (*2)
Alerts is a Laravel 5 package that allows you to easily flash alerts to the Session to be consumed on the next request., (*3)
First, install the package and it's dependencies with composer by running within your application's root folder:, (*4)
composer require augstudios/alerts
Then, you will need to add the the Alerts service provider and facade to your application's configuration in /app/config/app.php., (*5)
'providers' => [
...
'Augstudios\Alerts\AlertsServiceProvider'
];
...
'aliases' => [
...
'Alerts' => 'Augstudios\Alerts\AlertsFacade'
];
To flash messages, to be displayed on the next request, you can use the Alerts::flash(message, type) method:, (*6)
public function save()
{
Alerts::flash('Welcome Aboard!', 'info');
return Redirect::home();
}
There also exists some shortcut methods for each alert type:, (*7)
Alerts::flashInfo('Info message');
Alerts::flashWarning('Warning message');
Alerts::flashDanger('Danger message');
Alerts::flashSuccess('Success message');
To get the previously flashed alerts, use the Alerts::all() method:, (*8)
foreach(Alerts::all() as $alert){
// this is likely to change so Alert is an object
// $alert['message'] has message
// $alert['type'] has type
// $alert['dismissiable']
}
If you only want one type of alert, you can use the Alerts::ofType(type) method:, (*9)
Alerts::ofType('info');
Alerts::ofType('warning');
Alerts::ofType('danger');
Alerts::ofType('success');
Package for sending alerts with Laravel 5.
MIT
laravel alerts