grupodkt/notification-channel-waba

v5.8.3 2024-07-18 17:28 UTC

This package is not auto-updated.

Last update: 2024-09-27 05:45:32 UTC


README

Latest Version on Packagist Software License Total Downloads

此包使您能够使用 Laravel 5.4 轻松发送 [Waba 通知]。

安装

内容

安装

您可以通过 composer 安装此包

composer require grupodkt/notification-channel-waba

您必须安装服务提供者

// config/app.php
'providers' => [
    ...
    NotificationChannels\Waba\WabaProvider::class,
],

设置您的 Waba 账户

将您的 Waba Account SID、认证令牌和 phoneNumberId 添加到您的 config/services.php

// config/services.php
...
'waba' => [
    'url'   => env('WABA_URL'),
    'token' => env('WABA_TOKEN'),
    'phoneNumberId' => env('WABA_PHONE_NUMBER_ID'),
],
...

使用

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

use NotificationChannels\Waba\WabaChannel;
use NotificationChannels\Waba\WabaMessage;
use Illuminate\Notifications\Notification;

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

    public function toWaba($notifiable)
    {
        return (new WabaMessage())
            ->content("Your {$notifiable->service} account was approved!");
    }
}

为了让您的通知知道您要发送/拨打哪个电话,通道将在可通知模型中查找 celular 属性。如果您想覆盖此行为,请将 routeNotificationForWaba 方法添加到您的可通知模型中。

public function routeNotificationForWaba()
{
    return $this->mobile;
}

可用的消息方法

WabaSmsMessage

  • from(''):接受一个电话作为通知发送者。
  • content(''):接受一个字符串作为通知正文。

变更日志

请参阅 变更日志 了解最近的变化信息。

安全性

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

贡献

请参阅 贡献指南 获取详细信息。

致谢

许可证

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