jjsoft-ar / notification-module
处理实时通知的模块
1.4.0
2016-06-08 13:26 UTC
Requires
- php: >=5.4
- asgardcms/core-module: ~1.0
- composer/installers: ~1.0
Requires (Dev)
- orchestra/testbench: ~3.1
- phpunit/phpunit: ~4.0
README
快速向您的AsgardCms应用程序发送(实时)通知。
$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);
安装
在项目中要求模块
composer require asgardcms/notification-module
发布配置
php artisan module:publish notification
实时?
如果您想要通过WebSockets进行实时通知,您需要配置broadcasting.php
配置文件。完成此操作后,将asgard.notification.config.real-time
选项设置为true
。
目前,Laravel广播支持Pusher和Redis,但AsgardCms只为Pusher提供了前端集成。更多集成可以通过pull-request来欢迎。看看Pusher集成以获得灵感。
使用方法
使用简单直接
在需要的地方注入Modules\Notification\Services\Notification
接口并将其分配给类变量。
向已登录用户发送通知
$this->notification->push('New subscription', 'Someone has subscribed!', 'fa fa-hand-peace-o text-green', route('admin.user.user.index'));
向特定用户发送通知
$this->notification->to($userId)->push('New subscription', 'Someone has subscribed!', 'fa fa-hand-peace-o text-green', route('admin.user.user.index'));