premgthb/exabytes-sms
Composer 安装命令:
composer require premgthb/exabytes-sms
包简介
Laravel package for generating SMS using Exabytes API
README 文档
README
composer require premgthb/exabytes-sms
USAGE
Publish config files:
php artisan vendor:publish --provider="Premgthb\ExabytesSms\ExabytesServiceProvider"
.env Values:
EXABYTES_SMS_USERNAME = Your account username EXABYTES_SMS_PASSWORD = Your account password
Set up Notification class in your Laravel application using
php artisan make:notification ExabytesSmsNotification
and copy the code as follows
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Premgthb\ExabytesSms\Notifications\ExabytesSmsChannel; class ExabytesSmsNotification extends Notification { use Queueable; public $content; public function __construct($message) { $this->message = $message; } /** * Get the notification's delivery channels. */ public function via($notifiable) { return [ExabytesSmsChannel::class]; } /** * Get SMS Message content */ public function toExabytes($notifiable) { return $this->message; } }
In your User.php model:
public function routeNotificationForExabytes() { return preg_replace('/\D+/', '', '6'.$this->mobile_number); }
Finally use the following snippet in your controllers to trigger the Notification
Notification::route('exabytes', $mobileNumber)->notify(new ExabytesSmsNotification($yourMessage));
You are good to go!
ADDITIONAL
To generate 4 digit OTP code, in your controller:
use Exabytes; $otp = Exabytes::generateOtp();
To Send SMS without Queue:
$data = [ 'to' => $request->mobile_number , 'msg' => $request->message ] Exabytes::sendMessage($data);
统计信息
- 总下载量: 2.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-24