jurager / sender
此包已被废弃,不再维护。未建议替代包。
Laravel 提供程序,通过 SMS-assistent.by 发送短信
1.0
2023-01-20 09:14 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2023-02-20 09:33:40 UTC
README
Sender - Laravel 提供程序用于 SMS-assistent.by
安装
$ composer require jurager/sender
在 config/app.php 的 aliases 部分添加
'Sender' => Jurager\Sender\Sender::class,
运行以下命令发布包文件
php artisan vendor:publish --provider="Jurager\Sender\SenderServiceProvider"
使用
现在,如果您已配置 Queues,您可以在 /App/Http/Jobs 中创建如下 Job
<?php
namespace App\Jobs;
use Jurager\Sender\Sender;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SMS extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $to;
protected $text;
/**
* @param $to
* @param $text
*/
public function __construct($to, $text)
{
$this->to = $to;
$this->text = $text;
}
public function handle(Sender $sender)
{
$sender->sendOne($this->to, $this->text);
}
}
然后在您的应用程序的任何地方调度一个新的 Job
<?php
use App\Jobs\SMS;
class SampleController
{
$this->dispatch((new SMS( '+71234567890', 'Hello world!')))->delay(5));
}
许可证
此包是开源软件,许可协议为 MIT 许可协议。