2017 © Pedro Peláez
 

library flash

Easy flash notifications

image

standaniels/flash

Easy flash notifications

  • Tuesday, April 11, 2017
  • by standaniels
  • Repository
  • 2 Watchers
  • 7 Stars
  • 1,607 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 289 Forks
  • 0 Open issues
  • 15 Versions
  • 5 % Grown

The README.md

Easy Flash Messages for Your Laravel App

Forked from laracasts/flash to add support for multiple notifications., (*1)

Build Status, (*2)

Installation

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

Run composer require standaniels/flash, (*4)

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

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

Usage

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

public function store()
{
    flash('Welcome Aboard!');

    return home();
}

You may also do:, (*7)

  • flash('Message', 'info')
  • flash('Message', 'success')
  • flash('Message', 'danger')
  • flash('Message', 'warning')
  • flash()->overlay('Modal Message', 'Modal Title')
  • flash('Message')->important()

Behind the scenes, this will set a flash_notifications key which contains an array of messages. Every messages is an instance of Illuminate\Support\Collection:, (*8)

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

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

@foreach (flash()->all() as $message)


{!! $message->get('message') !!}
@endforeach

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

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

@include('flash::messages')

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::messages')

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

</body> </html>

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

php artisan vendor:publish

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

flash('Welcome Aboard!');

return home();

https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/message.png, (*15)

flash('Sorry! Please try again.', 'danger');

return home();

https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/error.png, (*16)

flash()->overlay('Notice', 'You are now a VIP!');

return home();

https://dl.dropboxusercontent.com/u/774859/GitHub-Repos/flash/overlay.png, (*17)

Hiding Flash Messages

A common desire is to display a flash message for a few seconds, and then hide it. To handle this, write a simple bit of JavaScript. For example, using jQuery, you might add the following snippet just before the closing </body> tag., (*18)

<script>
$('div.alert').not('.alert-important').delay(3000).fadeOut(350);
</script>

This will find any alerts - excluding the important ones, which should remain until manually closed by the user - wait three seconds, and then fade them out., (*19)

Credits

Special thanks to Jeffrey Way's laracasts/flash., (*20)

The Versions

11/04 2017

dev-master

9999999-dev

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stan Daniëls

11/04 2017

3.0.2

3.0.2.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stan Daniëls

11/04 2017

dev-feature-payload

dev-feature-payload

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stan Daniëls

18/01 2017

3.0.1

3.0.1.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stan Daniëls

15/11 2016

3.0.0

3.0.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stan Daniëls

11/07 2016

2.0.1

2.0.1.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

14/03 2016

2.0.0

2.0.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

22/12 2015

1.3.4

1.3.4.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2015

1.3.3

1.3.3.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2015

1.3.2

1.3.2.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

01/02 2015

1.3.1

1.3.1.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

13/09 2014

1.3

1.3.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

04/08 2014

1.2

1.2.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

25/07 2014

1.1

1.1.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires

30/06 2014

1.0

1.0.0.0

Easy flash notifications

  Sources   Download

MIT

The Requires

 

The Development Requires