2017 © Pedro Peláez
 

library laravel-flash-notifications

Easy way to display Flash Notifications in Laravel 5.

image

szykra/laravel-flash-notifications

Easy way to display Flash Notifications in Laravel 5.

  • Friday, January 22, 2016
  • by szykra
  • Repository
  • 3 Watchers
  • 7 Stars
  • 12,370 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 14 % Grown

The README.md

Laravel Flash Notifications

build version license downloads, (*1)

Flash Notifications Helper for Laravel 5, (*2)

Install

Install via composer

Add dependency to your composer.json file and run composer update., (*3)

require: {
    "szykra/laravel-flash-notifications": "~0.3"
}

Configure Laravel

Add ServiceProvider and Alias (Facade) to your config/app.php file:, (*4)

'Szykra\Notifications\NotificationServiceProvider'
'Flash' => 'Szykra\Notifications\Flash'

Include default alert view to your layout

Package default provides bootstrap ready alert view. Just include notifications::flash file to your main layout in blade:, (*5)

@include('notifications::flash')
````

You can create own container for flash notifications with own custom styles. See _Custom alert view_ section.

## Usage

You can push flash message ever you need by facade `Flash`. It provides 4 alert types:

* success
* error
* warning
* info

```php
Flash::info('Your alert message here!');

~~Method push() exists because you can push more than one alert at the same time. See below.~~, (*6)

Every alert method takes 1 or 2 arguments. If you give one parameter it will be message. If you provide two parameters, first will be title and second will be message., (*7)

Flash::success('User has been updated successfully.');
Flash::error('Oh snap!', 'Something went wrong. Please try again for a few seconds.');

Custom alert view

Package default provides bootstrap ready view for alerts. You can define own style for it. Just create new blade template file!, (*8)

@if(Session::has('flash.alerts'))
    @foreach(Session::get('flash.alerts') as $alert)

        <div class='alert alert-{{ $alert['level'] }}'>
            <button class="close" type="button" data-dismiss="alert" aria-hidden="true">&times;</button>

            @if( ! empty($alert['title']))
                <div><strong>{{ $alert['title'] }}</strong></div>
            @endif

            {{ $alert['message'] }}
        </div>

    @endforeach
@endif

All alerts will be in flash.alerts session variable. Single alert looks like:, (*9)

[
  'title' => 'Title',
  'message' => 'Example message',
  'level' => 'success'
]

Level for all alerts are following:, (*10)

  • Flash::success has level success
  • Flash::error has level danger
  • Flash::warning has level warning
  • Flash::info has level info

License

The MIT License. Copyright (c) 2014 - 2015 Szymon Krajewski., (*11)

The Versions

22/01 2016

dev-master

9999999-dev

Easy way to display Flash Notifications in Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

22/01 2016

0.3.3

0.3.3.0

Easy way to display Flash Notifications in Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

18/02 2015

0.3.2

0.3.2.0

Easy way to display Flash Notifications in Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

07/11 2014

0.3.1

0.3.1.0

Easy way to display Flash Notifications in Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

07/11 2014

dev-laravel4

dev-laravel4

Easy way to display Flash Notifications in Laravel 4.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

07/11 2014

0.2.1

0.2.1.0

Easy way to display Flash Notifications in Laravel 4.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

12/08 2014

0.2.0

0.2.0.0

Easy way to display Flash Notifications in Laravel 4.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Szymon Krajewski

laravel bootstrap messages notifications alerts flash

14/07 2014

0.1.1

0.1.1.0

Easy way to display Flash Notifications in Laravel 4.

  Sources   Download

MIT

The Requires

 

by Szymon Krajewski

laravel bootstrap notifications alerts flash

12/07 2014

0.1.0

0.1.0.0

Easy way to display Flash Notifications in Laravel 4.

  Sources   Download

MIT

The Requires

 

by Szymon Krajewski

laravel bootstrap alerts flash