xcoorp / laravel-novu-notifications
Novu Notifications通道用于Laravel。
v1.0.0
2024-06-26 07:13 UTC
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.0.1
- illuminate/notifications: ^10.0
- illuminate/support: ^10.0
Requires (Dev)
- laravel/pint: ^v1.13.7
- pestphp/pest: ^v2.28.1
- dev-main
- v1.0.0
- dev-dependabot/composer/laravel/pint-1.17.3
- dev-dependabot/composer/pestphp/pest-2.35.1
- dev-dependabot/composer/laravel/pint-1.17.2
- dev-dependabot/composer/guzzlehttp/guzzle-7.9.2
- dev-dependabot/composer/illuminate/notifications-10.48.15
- dev-dependabot/composer/illuminate/support-10.48.15
This package is auto-updated.
Last update: 2024-09-09 20:05:08 UTC
README
Novu - Laravel通知通道
此包简化了使用Novu发送通知的过程
class InvoicePaidNotification extends Notification { // Trigger a specific notification event public function toNovuEvent($notifiable) { return NovuMessage::create('workflow_1234') ->addVariable('invoice_id', $this->invoice->id) ->toSubscriberId('123456789'); } }
内容
安装
Novu通知通道可以通过Composer轻松安装
$ composer require xcoorp/laravel-novu-notifications
使用
要使用Novu通道发送通知,您需要在通知的via()
方法中指定通道
use NotificationChannels\Novu\NovuChannel; public function via($notifiable) { return [ NovuChannel::class ] }
API概览
Novu消息
命名空间: NotificationChannels\Novu\NovuMessage
NovuMessage
类包含了将被发送到Novu API的整个消息
static create(?string $workflowId)
实例化并返回一个新的NovuMessage
实例,可选地使用工作流程ID预先配置它workflowId(string $workflowId)
设置消息的workflowId
(您的novu工作流程触发ID)to(array $to)
包含接收者信息的数组,如subscriberId
、phone
等...toSubscriber(string $subscriberId)
设置接收者的subscriberId
variables(array $variables)
设置消息的变量(payload
)。这些是您的novu事件变量addVariable(string $key, $value)
向消息添加单个变量toArray()
返回将被发送到Novu API的数据数组
测试
此包的功能已通过Pest PHP测试。您可以使用以下命令运行测试
composer test
行为准则
为了确保社区对所有成员都持欢迎态度,请查阅并遵守行为准则。
安全漏洞
请查阅有关如何报告安全漏洞的安全策略。
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。