asgardcms/notification-module

处理实时通知的模块

安装次数4,982

依赖项: 0

建议者: 10

安全: 0

星标: 20

关注者: 7

分支: 15

开放问题: 4

类型:asgard-module

3.0.1 2017-10-11 08:14 UTC

This package is auto-updated.

Last update: 2024-09-08 07:40:52 UTC


README

Latest Version Software License Build Status Quality Score SensioLabs Insight

Total Downloads Total Downloads Total Downloads Slack

快速向您的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);

Notifications demo screenshot 快速演示

安装

模块下载

使用AsgardCMS的模块下载命令

php artisan asgard:download:module asgardcms/notification --migrations

这将下载模块并运行其迁移。

如果您想自定义字段、视图等,这是推荐的方式。

Composer

在您的终端中执行以下命令

composer require asgardcms/notification-module

注意:安装后,您需要在后端为博客模块页面分配所需的权限。

运行迁移

php artisan module:migrate notification

发布配置

php artisan module:publish-config notification

实时通知?

如果您想在WebSockets上实现实时通知,需要配置broadcasting.php配置文件。完成后,将asgard.notification.config.real-time选项设置为true

目前,Laravel broadcasting支持Pusher和Redis,但AsgardCms只有Pusher的前端集成。欢迎通过pull-request添加更多集成。查看Pusher集成以获取灵感。

要配置Pusher,您可以在.env文件中添加以下行

PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_ID=
PUSHER_APP_CLUSTER=us2
PUSHER_APP_ENCRYPTED=true

Pusher网站上应用程序的“入门”选项卡有一个.env部分的区域。您可以直接复制并粘贴这些内容。

用法

用法简单直接

在需要的地方注入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'));