An easy way to send notification messages to a client using AJAX in Laravel.
cornford/notifier is a Laravel package for an easy way to send notification messages to a client using ajax in laravel..
It currently has 5 GitHub stars and 575 downloads on Packagist (latest version v2.2.1).
Install it with composer require cornford/notifier.
Discover more Laravel packages by cornford
or browse all Laravel packages to compare alternatives.
Last updated
Think of Notifier as an easy way to send notification messages to a client using AJAX in Laravel. These include:
Notifier::notificationNotifier::noneNotifier::infoNotifier::successNotifier::warningNotifier::dangerNotifier::setOptionsNotifier::getOptionsNotifier::setNotificationsNotifier::getNotificationsNotifier::assetsNotifier::getDisplayNotificationsNotifier::displayNotificationsNotifier::displayedDisplayableNotificationsNotifier::displayedAllNotificationsNotifier::expireNotificationsNotifier::expireDisplayedNotificationsNotifier::expireAllNotificationsNotifier::fetchNotificationsNotifier::storeNotificationsNotifier::toArrayBegin by installing this package through Composer. Edit your project's composer.json file to require cornford/notifier.
"require": {
"cornford/notifier": "1.*"
}
Next, update Composer from the Terminal:
composer update
Once this operation completes, the next step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.
'Cornford\Notifier\Providers\NotifierServiceProvider',
The next step is to introduce the facade. Open app/config/app.php, and add a new item to the aliases array.
'Notifier' => 'Cornford\Notifier\Facades\NotifierFacade',
We then need to introduce the configuration files, JavaScripts and Stylesheets, by running the following command.
php artisan vendor:publish --provider="Cornford\\Notifier\\Providers\\NotifierServiceProvider"
That's it! You're all set to go.
It's really as simple as using the Logical class in any Controller / Model / File you see fit with:
Notifier::
This will give you access to
The notification method allows you to create a notification, with parameters for message, type and expiry as an integer of minutes or DateTime object.
Notifier::notification('This is a message', Notification::NOTIFICATION_TYPE_INFO, 0);
Notifier::notification('This is a message', Notification::NOTIFICATION_TYPE_NONE, new DateTime('tomorrow'));
The none method allows you to create a none notification, with parameters for message and expiry as an integer of minutes or DateTime object.
Notifier::none('This is a message', 0);
Notifier::none('This is a message', new DateTime('tomorrow'));
The info method allows you to create an information notification, with parameters for message and expiry as an integer of minutes or DateTime object.
Notifier::info('This is a message', 0);
Notifier::info('This is a message', new DateTime('tomorrow'));
The success method allows you to create a success notification, with parameters for message and expiry as an integer of minutes or DateTime object.
Notifier::success('This is a message', 0);
Notifier::success('This is a message', new DateTime('tomorrow'));
The warning method allows you to create a warning notification, with parameters for message and expiry as an integer of minutes or DateTime object.
Notifier::warning('This is a message', 0);
Notifier::warning('This is a message', new DateTime('tomorrow'));
The danger method allows you to create a danger notification, with parameters for message and expiry as an integer of minutes or DateTime object.
Notifier::danger('This is a message', 0);
Notifier::danger('This is a message', new DateTime('tomorrow'));
The danger method allows you to create a danger notification, with parameters for message and expiry as an integer of minutes or DateTime object.
Notifier::danger('This is a message', 0);
Notifier::danger('This is a message', new DateTime('tomorrow'));
The setOptions method allows you to set the current set of Notifier options using a parameter for options as an array.
Notifier::setOptions(['option' => 'value']);
The getOptions method allows you to fetch the current set of Notifier options as an array.
$options = Notifier::getOptions();
The setNotifications method allows you to the current set of notifications with an array of notifications objects.
Notifier::setNotifications([new Notification('This is a message', Notification::NOTIFICATION_TYPE_NONE, new DateTime('now'), 1)]);
The getNotifications method allows you to the fetch the current set of notifications as an array of notifications objects.
$notifications = Notifier::getNotifications();
The assets method allows you to the include the necessary Notifier assets to your template files, with an optional parameter for type.
{!! Notifier::assets() !!}
{!! Notifier::assets('cdn') !!}
The getDisplayNotifications method allows you to get the current set of displayable notifications.
$notifications = Notifier::getDisplayNotifications();
The displayNotifications method allows you to mark an array of passed notifications as displayed.
$notifications = Notifier::getNotifications();
Notifier::displayNotifications($notifications);
The displayedDisplayableNotifications method allows you to mark displayable notifications as displayed.
Notifier::displayedDisplayableNotifications();
The displayedAllNotifications method allows you to mark all notifications as displayed.
Notifier::displayedAllNotifications();
The expireNotifications method allows you to expire an array of passed notifications.
$notifications = Notifier::getNotifications();
Notifier::expireNotifications($notifications);
The expireDisplayedNotifications method allows you to expire all displayed notifications.
Notifier::expireDisplayedNotifications();
The expireAllNotifications method allows you to expire all notifications.
Notifier::expireAllNotifications();
The fetchNotifications method allows you to fetch all notifications from the session.
Notifier::fetchNotifications();
The storeNotifications method allows you to store all notifications into the session.
Notifier::storeNotifications();
The toArray method allows you convert an array of Notification objects to an array of arrays.
$notifications = Notifier::getNotifications();
Notifier::toArray($notifications);
Notifier is open-sourced software licensed under the MIT license