This package makes it easy to send notifications using Smsir with Laravel 5.5+, 6.x, 7.x , 8.x and 9.x
composer require rezahmady/smsir
First add these environment variables in your .env file:
SMSIR_API_KEY="xxxx"
SMSIR_SECRET_KEY="xxxx"
SMSIR_LINE_NUMBER="xxxx"
then add this method to your User model
public function routeNotificationForSmsir()
{
return $this->mobile;
}
sample notification class:
namespace App\Notifications\Sms;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Rezahmady\Smsir\SmsirChannel;
use Rezahmady\Smsir\SmsirMessage;
class VerificationCode extends Notification
{
use Queueable;
public $parameter;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($parameter)
{
$this->parameter = $parameter;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [SmsirChannel::class];
}
public function toSmsir($notifiable)
{
return (new SmsirMessage())
->setMethod('ultraFastSend')
->setTemplateId('47119')
->setParameters([
'VerificationCode' => $this->parameter
]);
}
}
sample trigger this notification :
return auth()->user()->notify(new VerificationCode('1234'));
A list of all available options
setMethod
is require
->setMethod('METHOD_NAME')
smsir has two method for send sms :
1. ultraFastSend
require attributes is parameters
(array) and templateId
(string)
set them with this chain methods :
->setTemplateId('THEMPLATE_ID')
->setParameters([...]);
2. sendVerificationCode
require attributes is code
(string)
set it with this chane method :
->setCode('YOUR_CODE')
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email ahmadireza15@gmail.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
Note: This package has been used to develop amirbagh75/smsir-php Thanks to Amirhossein Baghaie