Flash Message for Laravel 5.

v1.3.0 2017-11-13 04:48 UTC

This package is not auto-updated.

Last update: 2022-08-06 07:45:37 UTC


Build Status Latest Stable Version Total Downloads Latest Unstable Version License


Flash Message provides an expressive, easy-to-use flash notification in a Laravel 5 project. SweetAlert is supported out of the box.


To get started, you should add the gtk/flash-message Composer dependency to your project:

composer require gtk/flash-message

Once Flash Message is installed, you should register the Gtk\FlashMessage\FlashMessageServiceProvider service provider. Typically, this will be done automatically via Laravel's automatic service provider registration.

Getting Started

Within your controllers, before you perform a redirect...

public function store()
        'name' => request('name'),
        'email' => request('email'),

    flash()->success('Laradmin', 'User successfully created.');

    return redirect('/users');

Since SweetAlert is supported out of the box, you can append to the layout view:

<script src=""></script>


The result will be like:


Advanced Usage

You may also do:

  • flash()->info('Info Title!', 'Info Message.')
  • flash()->error('Error Title!', 'Error Message.')
  • flash()->warning('Warning Title!', 'Warning Message.')
  • flash()->danger('Danger Title!', 'Danger Message.')
  • flash()->overlay('Modal Title!', 'Modal Message.')

or even with custom key and custom level:

  • flash()->create('Custom Title!', 'Custom Message.', 'custom_level', 'custom_flash_message')

Behind the scenes, this will set a key in the session. Default is flash_message (or whatever you pass to) whose value is an array contains title, message and level (A string that represents the type of notification which is good for applying HTML class names) you're flashing.

With this message flashed to the session, you may now display it in your view(s). Maybe something like:

@if (session()->has('flash_message'))
    <div class="alert alert-{{ session('flash_message.level') }} alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <strong>{{ session('flash_message.title') }}</strong> {!! session('flash_message.message') !!}

Note that this package is optimized for use with Twitter Bootstrap.

Because flash messages and overlays are so common, if you want, you may use (or modify) the views that are included with this package. Simply append to your layout view:



<!DOCTYPE html>
<html lang="en">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Flash Message</title>
        <link rel="stylesheet" href="">
        <div class="container">

            <h1>Flash Message</h1>

        <script src="">
        <script src="">

If you need to modify the flash message partials, you can run:

php artisan vendor:publish

The default package view file default.blade.php will now be located in the app/views/packages/gtk/flash-message/ directory.


Flash Message is open-sourced software licensed under the MIT license.