2017 © Pedro Peláez
 

library flash

Flash notifications

image

mwa/flash

Flash notifications

  • Tuesday, June 7, 2016
  • by KhaledElmahdi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Flash Messages

Installation

First, pull in the package through Composer., (*1)

Run composer require mwa/flash, (*2)

And then, if using Laravel 5, include the service provider within config/app.php., (*3)

'providers' => [
    'MWA\Flash\FlashServiceProvider'
];

And, for convenience, add a facade alias to this same file at the bottom:, (*4)

'aliases' => [
    'Flash' => 'MWA\Flash\Flash'
];

Usage

Within your controllers, before you perform a redirect..., (*5)

public function store()
{
    Flash::message('Welcome Aboard!');

    return Redirect::home();
}

You may also do:, (*6)

  • Flash::info('Message')
  • Flash::success('Message')
  • Flash::error('Message')
  • Flash::warning('Message')
  • Flash::overlay('Modal Message', 'Modal Title')

Again, if using Laravel, this will set a few keys in the session:, (*7)

  • 'flash_notification.message' - The message you're flashing
  • 'flash_notification.level' - A string that represents the type of notification (good for applying HTML class names)

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

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flash()->success('You have been logged out.');

    return home();
}

Or, for a general information flash, just do: flash('Some message');., (*9)

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

@if (Session::has('flash_notification.message'))


{{ Session::get('flash_notification.message') }}
@endif

Note that this package is optimized for use with Twitter Bootstrap., (*11)

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:, (*12)

@include('flash::message')

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>



@include('flash::message')

Welcome to my website..., (*13)

</body> </html>

If you need to modify the flash message partials, you can run:, (*14)

php artisan vendor:publish

The two package views will now be located in the app/views/packages/mwa/flash/ directory., (*15)

The Versions

07/06 2016

dev-master

9999999-dev

Flash notifications

  Sources   Download

The Requires

 

The Development Requires

07/06 2016

1.1

1.1.0.0

Flash notifications

  Sources   Download

The Requires

 

The Development Requires

01/06 2016

v1.0

1.0.0.0

Flash notifications

  Sources   Download

The Requires

 

The Development Requires