Flash message in Laravel 5.5 example

Hi, Guys

In this tutorial i will let you know how to implement flash message in laravel 5.5 application. We can simply add info, success, error, warning and primary type of flash messages. Here in this tutorial i will use "mercuryseries/flashy" composer package, help of this package i will make simple example.

As we know well, flash message is very important to notify when record is created new, edited or deleted. So when you remove new record from list then flash message should appear "Item Deleted Successfully". I would be good to display this way message. So in this example you can see how i implemented flash message in laravel 5.5 from scratch.

You can see bellow screen shot flash message layout in corner green notification.

Step 1: Install mercuryseries/flashy Package

First of the thing is we have to install mercuryseries/flashy composer package for flash message. So simply run bellow composer command for install package.

composer require mercuryseries/flashy

After install successfully above mercuryseries/flashy package we need to add into providers and aliases array of configuration file. So let's add following way:



return [


'providers' => [




'aliases' => [


'Flashy' => MercurySeries\Flashy\Flashy::class,


Step 2: Add Route For Example

Now, in this step we will create new route for flash message and we will write code for generate flash message. So let's add following route:



Step 3: Add Method in HomeController

Here, we have to add flash() on HomeController file. So there we will write code for flash message, so add bellow method on HomeController:



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use PDF;

class HomeController extends Controller


public function flash()


flashy()->success('You get success notification.', 'hdtuto.com');

return view('flash');



Step 4: create flash.blade.php file

In last step, we have to add flash.blade.php view blade file. In this file we have to just write some html table code. So let's create blade file and put bellow code:


<!DOCTYPE html>

<html lang="en">


<meta charset="UTF-8">




<div class="container">

<p>Welcome to my website...</p>


<script src="//code.jquery.com/jquery.js"></script>




Now you are ready to run full example.

You can also set following flash message by this way:

Flashy::info('Message', 'http://your-awesome-link.com')

Flashy::success('Message', 'http://your-awesome-link.com')

Flashy::error('Message', 'http://your-awesome-link.com')

Flashy::warning('Message', 'http://your-awesome-link.com')

Flashy::primary('Message', 'http://your-awesome-link.com')

Flashy::primaryDark('Message', 'http://your-awesome-link.com')

Flashy::muted('Message', 'http://your-awesome-link.com')

Flashy::mutedDark('Message', 'http://your-awesome-link.com')

you can get more information about "mercuryseries/flashy" from here : mercuryseries/flashy.

I hope you found your best solution...

October 29, 2017 | 5041 Viewer | Category : PHP Laravel Bootstrap JQuery JQuery Plugin Laravel 5 Laravel 5.5
Related Posts