trez/raygan-sms-notification-channel

适用于 Laravel 5.3+ 的 Raygan SMS 通道

此包的规范存储库似乎已消失,因此已冻结此包。

2.0.1 2019-06-19 19:11 UTC

This package is not auto-updated.

Last update: 2023-04-06 13:59:56 UTC


README

此包使得使用 RayganSms API(GitHub 链接)在 Laravel 5.3+ 中发送通知变得容易。

RayganSms 通知通道用于 Laravel 5.3+

Latest Version on Packagist Software License StyleCI Scrutinizer Code Quality Build Status Code Intelligence Status Quality Score Total Downloads

此包通过使用 RayganSms API 提供发送通知的功能。

内容

安装和配置

您可以使用 composer 安装此服务。

composer require trez/raygan-sms-notification-channel
请注意,RayganSms API(GitHub 链接)将与此包一起自动安装到您的项目中。因此,如果您已在此项目中安装和配置了 RayganSms API 包,则安装过程将结束。否则,请根据该包的文档(Laravel 配置)进行操作。

使用方法

使用 ()via 方法将此通道添加到通知中,并添加以下 toRayganSms 方法来发送通知

use Illuminate\Notifications\Notification;
use NotificationChannels\RayganSms\RaygansmsChannel;
use NotificationChannels\RayganSms\TextMessage;
use NotificationChannels\RayganSms\AuthCodeMessage;

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

    public function toRayganSms($notifiable)
    {
        return (new TextMessage)
            ->content("your message to send ...");
    }
}
发送激活码给用户的示例
...
    public function toRayganSms($notifiable)
    {
        return (new AuthCodeMessage)
                    ->content('Welcome');
    }
    ...
如果我们想发送自定义的激活码
...
    public function toRayganSms($notifiable)
    {
        return (new AuthCodeMessage)
                    ->content('کد تایید شما : 325689')
                    ->autoGenerate(false);
    }

注意:为了确保将消息发送到用户,请使用模型(通常是 User 模型)来提取用户电话号码,首先将以下 trait 添加到您的模型中
    use Notifiable;
然后添加以下方法到模型中
    public function routeNotificationForRayganSms()
    {
        return $this->phone_number;
    }
请注意,在此模型中包含用户电话号码的列名为 phone_number。如果不同,请将 this->phone_number$ 替换为包含用户电话号码的列名。

创建者

许可证

此包的许可证是 MIT。有关此许可证的更多信息,请参阅 许可证文件