regoldidealista/esendex-laravel

这是一个用于与Esendex短信服务提供商集成的Laravel包,但如果需要,您也可以实现自己的服务作为备份。

1.0.1 2024-06-12 07:35 UTC

This package is not auto-updated.

Last update: 2024-10-02 09:18:40 UTC


README

这是一个用于与Esendex短信服务集成的Laravel包,您还可以设置自己的备份提供商。

安装

composer require regoldidealista/esendex-laravel

用法

  1. 在您的config/app.php文件中注册服务提供者
'providers' => [
    // Other Service Providers...

    Regoldidealista\EsendexLaravel\SmsServiceProvider::class,
],
  1. 发布配置文件
    安装包后,您应该在Laravel应用程序中发布配置文件。这将允许您修改包的配置选项。在您的终端中运行以下命令
php artisan vendor:publish --provider="Regoldidealista\EsendexLaravel\SmsServiceProvider" 

此命令将包中的sms.php配置文件发布到Laravel应用程序的config目录。您可以在config/sms.php中找到已发布的配置文件。

  1. 使用SmsNotification类发送短信通知
use Regoldidealista\EsendexLaravel\Notifications\SmsNotification;

class YourNotification extends SmsNotification
{
    // use the via method with the specific channel 
    public function via(object $notifiable): string
    {
        return $this->channel::class;
    }
    // also you can implement viaQueues method using the same channel.

    public function beforeSend(): void
    {
        // you can get notifiable object with $this->getNotifiable()
        $this->setTo(); // set the recipient phone number or array of phone numbers
        $this->setBodyMessage(); // set the body message as a string
    }
}