Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

moririnson/laravel-line-notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Notifications for LINE Notify Build Status

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.

About

Laravel Notifications for LINE Notify

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages