diviky/laravel-messenger-people

短信通知的首选驱动程序

v1.0.2 2020-10-12 10:01 UTC

This package is auto-updated.

Last update: 2024-09-12 18:36:34 UTC


README

内容

安装

您可以通过composer安装此包

composer require diviky/laravel-messenger-people

设置账户

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

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

使用

现在您可以在通知中的 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)。有关更多信息,请参阅 许可证文件