yudina/laravel-sms is a Laravel package for sms provider.
It currently has 0 GitHub stars and 24 downloads on Packagist (latest version 0.0.7).
Install it with composer require yudina/laravel-sms.
Discover more Laravel packages by yudina
or browse all Laravel packages to compare alternatives.
Last updated
This package makes it easy to send SMS notifications for some sms providers with Laravel 5.8.
Supported SMS providers:
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"
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=
...
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;
}
}