augstudios/alerts

This package is abandoned and no longer maintained. No replacement package was suggested.

Package for sending alerts with Laravel 5.

dev-master / 1.0.x-dev 2015-03-03 23:43 UTC

This package is not auto-updated.

Last update: 2020-08-21 19:01:50 UTC


README

Build Status Total Downloads License

About

This package is in very early initial development, things are very likely going change before a stable release is tagged.

Alerts is a Laravel 5 package that allows you to easily flash alerts to the Session to be consumed on the next request.

Installation

First, install the package and it's dependencies with composer by running within your application's root folder:

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.

'providers' => [
    ...
    'Augstudios\Alerts\AlertsServiceProvider'
];
...

'aliases' => [
	...
    'Alerts' => 'Augstudios\Alerts\AlertsFacade'
];

Usage

To flash messages, to be displayed on the next request, you can use the Alerts::flash(message, type) method:

public function save()
{
    Alerts::flash('Welcome Aboard!', 'info');

    return Redirect::home();
}

There also exists some shortcut methods for each alert type:

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:

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:

Alerts::ofType('info');
Alerts::ofType('warning');
Alerts::ofType('danger');
Alerts::ofType('success');