# Easy Flash Messages ## Installation First, pull in the package through Composer. Run `composer require laracasts/flash` And then, if using Laravel 5, include the service provider within `config/app.php`. ```php 'providers' => [ 'Laracasts\Flash\FlashServiceProvider' ]; ``` And, for convenience, add a facade alias to this same file at the bottom: ```php 'aliases' => [ 'Flash' => 'Laracasts\Flash\Flash' ]; ``` ## Usage Within your controllers, before you perform a redirect... ```php public function store() { Flash::message('Welcome Aboard!'); return Redirect::home(); } ``` You may also do: - `Flash::info('Message')` - `Flash::success('Message')` - `Flash::error('Message')` - `Flash::warning('Message')` - `Flash::overlay('Modal Message', 'Modal Title')` Again, if using Laravel, this will set a few keys in the session: - 'flash_notification.message' - The message you're flashing - 'flash_notification.level' - A string that represents the type of notification (good for applying HTML class names) Alternatively, again, if you're using Laravel, you may reference the `flash()` helper function, instead of the facade. Here's an example: ```php /** * Destroy the user's session (logout). * * @return Response */ public function destroy() { Auth::logout(); flash()->success('You have been logged out.'); return home(); } ``` Or, for a general information flash, just do: `flash('Some message');`. With this message flashed to the session, you may now display it in your view(s). Maybe something like: ```html @if (Session::has('flash_notification.message'))
Welcome to my website...