Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
/ laravel5-flash Public archive

Laravel 5 Flash messages inspired by Laracasts Flash Messages

License

Notifications You must be signed in to change notification settings

willishq/laravel5-flash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel 5 Flash Message Helper

Inspired by Laracasts Flash

Installation

Install via composer:

composer require willishq/laravel5-flash

Usage

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:

@if($flash->exists())
	@if($flash->isPanel())
		<div class="panel">
			<h5>{{ $flash->title }}</h5>
			<p>{{ $flash->message }}</p>
		</div>
	@else
		<div data-alert class="alert-box {{ $flash->type }}">
			<p>{{ $flash->message }}</p>
			<a href="#" class="close">&times;</a>
		</div>
	@endif

@endif

About

Laravel 5 Flash messages inspired by Laracasts Flash Messages

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages