Package Data | |
---|---|
Maintainer Username: | bradcornford |
Maintainer Contact: | me@bradleycornford.co.uk (Bradley Cornford) |
Package Create Date: | 2015-08-20 |
Package Last Update: | 2020-11-05 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:13:29 |
Package Statistics | |
---|---|
Total Downloads: | 575 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Think of Notifier as an easy way to send notification messages to a client using AJAX in Laravel. These include:
Notifier::notification
Notifier::none
Notifier::info
Notifier::success
Notifier::warning
Notifier::danger
Notifier::setOptions
Notifier::getOptions
Notifier::setNotifications
Notifier::getNotifications
Notifier::assets
Notifier::getDisplayNotifications
Notifier::displayNotifications
Notifier::displayedDisplayableNotifications
Notifier::displayedAllNotifications
Notifier::expireNotifications
Notifier::expireDisplayedNotifications
Notifier::expireAllNotifications
Notifier::fetchNotifications
Notifier::storeNotifications
Notifier::toArray
Begin 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