moririnson / laravel-line-notify
line notify for laravel
Installs: 5 450
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=7.0
- guzzlehttp/guzzle: >=6.0
- illuminate/notifications: >=6.0
Requires (Dev)
- mockery/mockery: *
- orchestra/testbench: >=4.0
- phpunit/phpunit: >=6.0
- squizlabs/php_codesniffer: 3.*
README
Requirement
- PHP 7.0+
- Laravel 5.5+
Installation
composer require moririnson/laravel-line-notify
Usage
Notification
Add token to your notifiable.
/** * @return string token */ public function routeNotificationForLINE() { return 'ACCESS_TOKEN_HERE'; }
Create your notification by make:notification
and impl like this.
use Illuminate\Notifications\Notification; use Moririnson\LINENotify\Channels\LINENotifyChannel; use Moririnson\LINENotify\Messages\LINENotifyMessage; class LineNotify extends Notification { private $message; public function __construct($message) { $this->message = $message; } public function via($notifiable) { return [LINENotifyChannel::class] } public function toLINE($notifiable) { return (new LINENotifyMessage())->message($this->message); } }
Then you can call notify()
.
$notifiable->notify(new LINENotify('test message'));
Logging
Add this config to logging.php
.
'stack' => [
'driver' => 'stack',
'channels' => ['line'],
],
'line' => [
'driver' => 'custom',
'token' => env('LOG_LINE_NOTIFY_ACCESS_TOKEN'),
'via' => \Moririnson\LINENotify\Logging\LINENotifyLogger::class,
'level' => 'error',
],
Testing
composer test
License
The MIT License (MIT), Please see License File for more information.