yudina/laravel-sms
Composer 安装命令:
composer require yudina/laravel-sms
包简介
Sms provider
README 文档
README
This package makes it easy to send SMS notifications for some sms providers with Laravel 5.8.
Supported SMS providers:
Installation
Add SmsNotification package to your Laravel project via composer:
composer required yudina/laravel-sms
Then publish configuration file:
php artisan vendor:publish --provider="Yudina\LaravelSms\SmsSenderServiceProvider"
Settings up your account for select sms provider
Add the environment variables to your config/services.php:
// config/services.php ... 'default' => env('SMS_PROVIDER', 'smscru'), 'providers' => [ 'smsru' => [ 'api_id' => env('SMSRU_API_ID') ], 'smscru' => [ 'login' => env('SMSCRU_LOGIN'), 'password' => env('SMSCRU_PASSWORD'), 'sender' => env('SMSCRU_SENDER') ], ... ] ...
Add your necessary keys to your .env:
// .env SMSRU_API_ID= ...
Usage
Now you can use the channel in your via() method inside the notification:
use Yudina\LaravelSms\SmsSenderChannel; use Yudina\LaravelSms\SmsSenderMessage; use Illuminate\Notifications\Notification; class CodeGenerationNotification extends Notification { public function via($notifiable) { return [SmsSenderChannel::class]; } public function toSms($notifiable) { $message = 'Activation code: ' . $this->generateCode(6); return new SmsSenderMessage($message); } private function generateCode(int $length): string { $result = ''; for($i = 0; $i < $length; $i++) $result .= mt_rand(0, 9); return $result; } }
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-22