aliinateghiii / smsir
1.0.0
2021-04-26 15:32 UTC
Requires
- php: ~7.3
- ext-json: *
- guzzlehttp/guzzle: ^7.0.1
- illuminate/notifications: ~6.0 || ~7.0 || ~8.0
- illuminate/support: ~6.0 || ~7.0 || ~8.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-19 01:55:17 UTC
README
此包简化了使用Smsir发送通知的过程,支持Laravel 5.5+、6.x、7.x和8.x
内容
安装
composer require rezahmady/smsir
设置Smsir服务
首先在您的 .env 文件中添加以下环境变量
SMSIR_API_KEY="xxxx"
SMSIR_SECRET_KEY="xxxx"
SMSIR_LINE_NUMBER="xxxx"
然后添加此方法到您的 User 模型中
public function routeNotificationForSmsir()
{
return $this->mobile;
}
用法
示例通知类
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
]);
}
}
示例触发此通知
return auth()->user()->notify(new VerificationCode('1234'));
可用的消息方法
所有可用选项的列表
setMethod
必需
->setMethod('METHOD_NAME')
smsir有两种发送短信的方法
1. ultraFastSend 必需属性是 parameters
(数组)和 templateId
(字符串),通过以下链式方法设置它们
->setTemplateId('THEMPLATE_ID')
->setParameters([...]);
2. sendVerificationCode
必需属性是 code
(字符串),通过以下链式方法设置
->setCode('YOUR_CODE')
变更日志
请参阅CHANGELOG获取更多信息。
测试
$ composer test
安全性
如果您发现任何安全相关的问题,请通过电子邮件ahmadireza15@gmail.com报告,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅CONTRIBUTING。
致谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。
注意:此包已用于开发amirbagh75/smsir-php。感谢Amirhossein Baghaie。