Flash message management for Laravel 5.

v0.2 2015-01-28 14:50 UTC

This package is auto-updated.

Last update: 2020-06-12 17:51:15 UTC


Inspired by Laracasts Flash


Install via composer:

composer require willishq/laravel5-flash


Ideally use within your base controller as so:

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Willishq\Flash\Flash;

abstract class Controller extends BaseController {

	use DispatchesCommands, ValidatesRequests;
	 * @var Flash
	protected $flash;
	public function __construct(Flash $flash)
		$this->flash = $flash;

To fire off a flash message:

class FooController extends BaseController {

	public function somethingNeat()
	    // epic codes
	    $this->flash->success('success message');
	    return redirect('/');

To display flash messages in your view:

		<div class="panel">
			<h5>{{ $flash->title }}</h5>
			<p>{{ $flash->message }}</p>
		<div data-alert class="alert-box {{ $flash->type }}">
			<p>{{ $flash->message }}</p>
			<a href="#" class="close">&times;</a>