Kagga / Flash by Kagga

Package to simply and beautify Flash messages in Laravel 5
53
0
1
Package Data
Maintainer Username: Kagga
Maintainer Contact: johnkagga@gmail.com (Kagga)
Package Create Date: 2016-02-16
Package Last Update: 2016-02-16
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-24 03:01:33
Package Statistics
Total Downloads: 53
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Simple Flash Messages

Lets get started

Installation

Install this package through composer

Simply run composer require kagga/flash

If using Laravel 5 add the service provider in config/app.php.

'providers' => [
    Kagga\Flash\FlashServiceProvider::class
];

For convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'Flash' => Kagga\Flash\Facade\Flash::class
];

Usage

Within your controllers, before the redirect

public function update()
{
    Flash::success('Update','Successfully Updated');

    return Redirect::home();
}

You may also do:

  • Flash::info('Title','Message')
  • Flash::success('Title','Message')
  • Flash::error('Title','Message')
  • Flash::warning('Title','Message')
  • Flash::overlay('Title',' Message', 'Level') By default the level is success you can override if you specify a level.

This package will set a few keys in the session.

  • 'message' - The session key.
  • 'message_overlay' - The session key for an overlay.

Alternatively, if you're using Laravel, you may reference the flash() helper function, instead of the facade. Here's an example:

public function store()
{

    flash()->success('Title','Message');

    return Redirect::home();
}

This package makes use of sweetalert http://t4t5.github.io/sweetalert/

Add the Javascript and css files from http://t4t5.github.io/sweetalert/ to your views

To add the Flash view to your view just include it has shown below.

@include('flash::flash')

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

php artisan vendor:publish

The package view will now be located in the \resources\views\vendor\flash directory.