diviky/laravel-notification-channel-botman

使用 botman 作为 Laravel 通知服务

v1.0.1 2020-11-03 05:28 UTC

This package is auto-updated.

Last update: 2024-08-29 05:37:13 UTC


README

内容

安装

您可以通过 composer 安装此包

composer require diviky/laravel-notification-channel-botman

设置您的账户

将您的配置添加到 config/services.php

// config/services.php
...
'messengerpeople' => [
    'client_id' => env('MP_CLIENT_ID'),
    'client_secret' => env('MP_CLIENT_SECRET'),
    'uuid' => env('MP_UUID'),
],
...

使用

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

use NotificationChannels\MessengerPeople\Channel;
use NotificationChannels\MessengerPeople\Message;
use Illuminate\Notifications\Notification;

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

    public function toMessengerPeople($notifiable)
    {
        return (new Message())
            ->text("Your {$notifiable->service} account was approved!");
    }
}

为了让您的通知知道您要发送到哪个手机,该通道将查找可通知模型中的 phone_number 属性和 mobile。如果您想覆盖此行为,请将 routeNotificationForMessengerPeople 方法添加到您的可通知模型中。

public function routeNotificationForMobtexting()
{
    return '+1234567890';
}

可用的消息方法

  • from(''):接受一个用于通知发送者的手机号码。
  • text(''):接受一个字符串值作为通知正文。
  • to(''):接受一个字符串值作为通知接收者(覆盖默认值)。

贡献

有关详细信息,请参阅 CONTRIBUTING

许可证

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