- PHP 7.0+
- Laravel 5.5+
composer require moririnson/laravel-line-notify
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'));
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',
],
composer test
The MIT License (MIT), Please see License File for more information.