New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

lloople/laravel-notificator

Attach objects to notification's session flashed variable
164 2
Install
composer require lloople/laravel-notificator
Latest Version:v1.6.0
PHP:>=7.1
Laravel:5
License:MIT
Last Updated:Feb 8, 2018
Links: GitHub  ·  Packagist
Maintainer: lloople

Laravel Notificator

Simple session flashing messages manager for Laravel

Notifications are stored in Laravel's session flash input, keyed by notifications

Create a notification

Notificator::success('This is a success notification');

You can choose between 4 types

  • success
  • info
  • error
  • warning

Print a notification

@foreach(Notificator::all() as $notification)
    <div class="alert alert-{{ $notification->getBootstrapClass() }}>
        <p>{{ $notification->getMessage() }}</p>
    </div>
@endforeach

getBootstrapType() transforms the error type into danger to use it with Bootstrap default CSS alerts. If you're not using Bootstrap, you can use getType to get it as error.

If you just want the first notification or you know you'll work with just one, you can use

 Notificator::first()->getMessage();

Duration

Notification's Messages also have an integer $duration in case you use a javscript library like toastr.js

You can modify the default duration of 5 seconds when creating the notification

Notificator::success('Message', 10000); // 10 seconds

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
v1.6.0 >=7.1 5.5.* || 5.6.* MIT
v1.5.3 >=7.0 5.5.* MIT
v1.5.2 >=7.0 5.5.* MIT
v1.5.1 >=7.0 5.5.* MIT
v1.5 >=7.0 MIT