boring-dragon/msgowl-laravel-notification-channel

MsgOwl 通知通道适用于 Laravel

v1.0.4 2023-05-27 13:14 UTC

This package is auto-updated.

Last update: 2024-09-27 16:07:37 UTC


README

cover

Run PHP Unit Tests

安装

您可以通过 composer 安装此包

composer require boring-dragon/msgowl-laravel-notification-channel

设置您的 MsgOwl 凭据

将环境变量添加到您的 config/services.php

// config/services.php
...
'msgowl' => [
    'sender_id' => env('MSGOWL_SENDER_ID'),
    'api_key' => env('MSGOWL_API_KEY'),
    'recipients' => env('MSGOWL_RECIPIENTS'),
],
...

将您的 MsgOwl API 密钥、默认发送者 ID 和默认收件人添加到您的 .env

// .env
...
    MSGOWL_SENDER_ID=
    MSGOWL_API_KEY=
    MSGOWL_RECIPIENTS=
],
...

用法

现在您可以在通知内的 via() 方法中使用此通道

use BoringDragon\MsgowlLaravelNotificationChannel\MsgOwlChannel;
use BoringDragon\MsgowlLaravelNotificationChannel\MsgOwlMessage;
use Illuminate\Notifications\Notification;

class UserApproved extends Notification
{
    public function via($notifiable)
    {
        return [MsgOwlChannel::class];
    }

    public function toMsgOwl($notifiable)
    {
        return (new MsgOwlMessage("You are approved by the system"));
    }
}

您可以为收件人添加单个值或数组

return (new MsgOwlMessage("You are approved by the system"))->setRecipients($recipients);

或者,您可以在可通知模型中添加一个 routeNotificationForMsgOwl 方法来返回电话号码

public function routeNotificationForMsgOwl() : string
{
    return $this->mobile;
}

参考

安全

如果您发现任何安全相关的问题,请通过电子邮件 boringdragon98@gmail.com 反馈,而不是使用问题跟踪器。

致谢

许可协议

MIT 许可协议 (MIT)。请参阅 许可文件 获取更多信息。

免责声明

此包与 MsgOwl 没有任何官方联系。