Laravel Bones Flash Notification (bones-flash)
Installation
To install bones-flash as a stand-alone module:
composer require genealabs/bones-flash:*
or add it to you composer.json file:
"require": {
/* ... */,
"genealabs/bones-flash": "*"
},
/* ... */
And then add the service provider to your app.php config file:
// 'providers' => array(
'GeneaLabs\Bones\Flash\BonesFlashServiceProvider',
// );
Usage
You can add any one of the following alerts anywhere in your app. Most common-place is probably the controller or global.php (for error catching).
use GeneaLabs\Bones\Flash\Flash;
class MyController extends BaseController
{
public function index()
{
Flash::info("test");
return View::make('index');
}
}
And include it in your index.blade.php where you would like the notification to appear:
@include('bones-flash::bones.flash')
or:
App::error(function(Exception $exception, $code)
{
Flash::danger("An error occurred");
Log::error($exception);
View::make('my.view');
});
Methods
The following methods are available to use:
// shows a bootstrap success message
Flash::success($message);
// shows a bootstrap info message
Flash::info($message);
// shows a bootstrap warning message
Flash::warning($message);
// shows a bootstrap danger message
Flash::danger($message);
// shows a message in a bootstrap modal window
Flash::modal($message);
Dependencies
At this time this package requires:
- Laravel 5.0+
- Bootstrap 3.1+
- jQuery 1.7+