jjsoft-ar / notification-module
Module handling the real time notifications
Installs: 4
Dependents: 0
Suggesters: 1
Security: 0
Stars: 0
Watchers: 2
Forks: 15
Type:asgard-module
Requires
- php: >=5.4
- asgardcms/core-module: ~1.0
- composer/installers: ~1.0
Requires (Dev)
- orchestra/testbench: ~3.1
- phpunit/phpunit: ~4.0
README
Quickly send (real-time) notifications to your AsgardCms application.
$this->notification->push('New subscription', 'Someone has subscribed!', 'fa fa-hand-peace-o text-green', route('admin.user.user.index'));
/** * Push a notification on the dashboard * @param string $title * @param string $message * @param string $icon * @param string|null $link */ public function push($title, $message, $icon, $link = null);
Installation
Require the module in your project
composer require asgardcms/notification-module
Publish the configuration
php artisan module:publish notification
Real time ?
If you want real time notifications over websockets, you need to configure the broadcasting.php
config file. After that is done, set the asgard.notification.config.real-time
option to true
.
Currently, Laravel broadcasting supports Pusher and Redis, but AsgardCms only has the front-end integration for Pusher. More integrations are welcome via pull-request. Look at the Pusher integration for inspiration.
Usage
Usage is simple and straightforward:
Inject the Modules\Notification\Services\Notification
interface where you need it and assign it to a class variable.
Send notification to logged in user
$this->notification->push('New subscription', 'Someone has subscribed!', 'fa fa-hand-peace-o text-green', route('admin.user.user.index'));
Send notification to a specific user
$this->notification->to($userId)->push('New subscription', 'Someone has subscribed!', 'fa fa-hand-peace-o text-green', route('admin.user.user.index'));