Skip to content

Laravel notificator allows you to easy add messages onto Laravel's session as an array called notifications

License

Notifications You must be signed in to change notification settings

Lloople/laravel-notificator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Laravel notificator allows you to easy add messages onto Laravel's session as an array called notifications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages