LaravelPackages.net
Acme Inc.
Toggle sidebar
fcorz/laravel-line-notify

My awesome package

46
6
1.0.0
About fcorz/laravel-line-notify

fcorz/laravel-line-notify is a Laravel package for my awesome package. It currently has 6 GitHub stars and 46 downloads on Packagist (latest version 1.0.0). Install it with composer require fcorz/laravel-line-notify. Discover more Laravel packages by fcorz or browse all Laravel packages to compare alternatives.

Last updated

laravel-line-notify

:rainbow: laravel line notify notification

Latest Version on Packagist Build Status Total Downloads License: MIT

Laravel implements the line notify message notification function. Including the binding of code in exchange for access token and notification channel message push.

Installation

you can install the package via composer:

composer require fcorz/laravel-line-notify

publish config

php artisan vendor:publish --provider="Fcorz\LaravelLineNotify\LaravelLineNotifyServiceProvider"

Usage

simple

// 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");

facade

// get access_token by code
LaravelLineNotifyFacade::getAccessToken("O97YoWeYMV6vW3uYPFgPAC");

// notify
$message = (new LaravelLineMessage())->message('hello world');
LaravelLineNotifyFacade::sendNotify($message, "access_token");

notification

user model notifiable

public function routeNotificationForLine($notification)
{
    return $this->notify_access_token;
}

create your notification ( you can also not use the queue )

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);
    }
}

call notify()

$receiver->notify(new LineNotification('hello world'));

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Star History Chart