dustinhsiao21 / laravel-line-notify
line notify webhook 包
dev-master
2019-06-13 09:38 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ~6.0
- illuminate/notifications: 5.3.*|5.4.*|5.5.*
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/database: 3.3.x-dev|^3.5.0
- orchestra/testbench: 3.3.x-dev|^3.5.0
- phpunit/phpunit: 4.*|~6.0
- squizlabs/php_codesniffer: 3.*
This package is not auto-updated.
Last update: 2024-09-29 05:41:53 UTC
README
要求
- PHP 7.0+
- Laravel 5.3+
安装
composer require dustinhsiao21/laravel-line-notify
使用
将 routeNotificationForLine 方法添加到您的 Notifiable 模型中。此方法需要返回您的 Line Notify OAuth2 令牌。 阅读文档
/** * @return string Line Notify OAuth2 token */ public funtcion routeNotificationForLine() { return 'ADD_YOUR_ACCESS_TOKEN_HERE'; }
然后您可以在通知的 via() 方法中使用此通道。您还可以添加 toLine() 方法。
<?php namespace App\Notifications; use dustinhsiao21\LineNotify\LineChannel; use dustinhsiao21\LineNotify\LineMessage; use Illuminate\Notifications\Notification; class LineNotify extends Notification { private $message; public funtion __construct($message) { $this->message = $message; } public funtcion via($notifiable) { return [LineChannel::class] } public funtcion toLine($notifiable) { return (new LineMessage())->message($message); } }
现在您可以使用 notifiable->notify() 发送通知。例如,如果您使用 user 作为模型。
$user = User::find(1); $user->notify(New LineNotify('Hello World'));
测试
composer test
安全
如果您发现任何安全问题,请通过电子邮件发送至 dustinhsiao21@gmail.com,而不是使用问题跟踪器。
许可证
MIT 许可证 (MIT),有关更多信息,请参阅 许可证文件。