fcorz / laravel-line-notify
我的优秀包
1.0.0
2021-02-25 03:38 UTC
Requires
- php: ^7.2
- guzzlehttp/guzzle: ^6.3|^7.0.1
- illuminate/notifications: ^6.0|^7.0|^8.0
- illuminate/support: ^5.8|^6.0|^7.0|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- orchestra/testbench: ^3.8|^4.0|^5.0|^6.0
- phpunit/phpunit: ^7.0|^8.0|^9.0
README
🌈 Laravel 行通知通知
Laravel 实现了行通知消息通知功能。包括绑定代码以换取访问令牌和通知渠道消息推送。
安装
您可以通过 composer 安装此包
composer require fcorz/laravel-line-notify
发布配置
php artisan vendor:publish --provider="Fcorz\LaravelLineNotify\LaravelLineNotifyServiceProvider"
用法
简单
// get access_token by code app('line-notify')->getAccessToken("O97YoWeYMV6vW3uYPFgPAC"); // response { "status":200, "message":"access_token is issued", "access_token":"1vIvPoq4aG4UOJYoQ6oriAUPvDNxxxxxxxxxxx" } // notify $message = (new LaravelLineMessage())->message('hello world'); app('line-notify')->sendNotify($message, "access_token");
外观
// get access_token by code LaravelLineNotifyFacade::getAccessToken("O97YoWeYMV6vW3uYPFgPAC"); // notify $message = (new LaravelLineMessage())->message('hello world'); LaravelLineNotifyFacade::sendNotify($message, "access_token");
通知
用户模型可通知
public function routeNotificationForLine($notification) { return $this->notify_access_token; }
创建您的通知(您也可以不使用队列)
use App\Models\UserMessage; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Notification; class LineNotification extends Notification implements ShouldQueue { use Queueable; protected $message; public function __construct($message, $delay = 0) { $this->queue = 'notification'; $this->delay = $delay; $this->message = $message; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return ['line']; } /** * @param $notifable * @return LineTemplateService */ public function toLineNotify($notifable) { return (new LaravelLineMessage())->message($this->message); } }
调用 notify()
$receiver->notify(new LineNotification('hello world'));
安全性
如果您发现任何安全问题,请通过电子邮件 fengchenorz@gmail.com 联系,而不是使用问题跟踪器。
致谢
许可协议
MIT 许可协议(MIT)。有关更多信息,请参阅 许可文件。