forss / laravel-forss-sms-notifications
sms.forss.net 的 SMS 通知驱动
1.0.1
2023-06-21 13:49 UTC
Requires
- guzzlehttp/guzzle: ^7.7
This package is auto-updated.
Last update: 2024-09-21 16:20:39 UTC
README
设置 forss API 服务
扩展 config/services.php
以从 .env
读取您的 Forss SMS API 凭证
return [ ... 'forss_sms' => [ 'username' => env('FORSS_SMS_USERNAME'), 'password' => env('FORSS_SMS_PASSWORD'), 'sender' => env('FORSS_SMS_SENDER'), ] ];
将您的 Forss SMS API 凭证添加到您的 .env
FORSS_SMS_USERNAME=username FORSS_SMS_PASSWORD=password FORSS_SMS_SENDER=sender
用法
创建通知
为您的 Notification 类添加 toForssSms
方法
namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Forss\Laravel\Notifications\ForssSms\ForssSmsMessage; use Forss\Laravel\Notifications\ForssSms\ForssSmsChannel; class TestSms extends Notification { use Queueable; /** * Create a new notification instance. */ public function __construct() { // } /** * Get the notification's delivery channels. * * @return array<int, string> */ public function via(object $notifiable): array { return [ForssSmsChannel::class]; } public function toForssSms() { return ForssSmsMessage::create('Hello World'); } }
为您的 Notifiable 类添加 routeNotificationForForssSms
方法
class User extends Authenticatable { use Notifiable; public function routeNotificationForForssSms() { //Return whatever phone number to use for the SMS return $this->phone; } }