Skip to content

yajianguo/lark-notification-channel

Repository files navigation

Lark notifications channel for Laravel

This package makes it easy to send Lark using the Laravel notification system. Supports 5.5+, 6.x, 7.x and 8.x.

Contents

Installation

You can install the package via composer:

composer require yajianguo/lark-notification-channel

Usage

Now you can use the channel in your via() method inside the notification:

use NotificationChannels\Lark\LarkChannel;
use NotificationChannels\Lark\LarkMessage;
use Illuminate\Notifications\Notification;

class ProjectCreated extends Notification
{
    public function via($notifiable)
    {
        return [LarkChannel::class];
    }

    public function toLark($notifiable)
    {
        return LarkMessage::create()
            ->url('https://open.feishu.cn/open-apis/bot/v2/hook/selfPath')
            ->data([
               'payload' => [
                   'lark' => 'data'
               ]
            ])
            ->userAgent("Custom-User-Agent")
            ->header('X-Custom', 'Custom-Header');
    }
}

In order to let your Notification know which URL should receive the Lark data, add the routeNotificationForLark method to your Notifiable model.

Url or Model POST request.

public function routeNotificationForLark()
{
    return 'http://requestb.in/1234x';
}

Available methods

  • url(''): Accepts a string value for the Lark url.
  • data(''): Accepts a JSON-encodable value for the Lark body.
  • query(''): Accepts an associative array of query string values to add to the request.
  • userAgent(''): Accepts a string value for the Lark user agent.
  • header($name, $value): Sets additional headers to send with the POST Lark.

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email a@a.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

About

Lark Notification Channel for laravel.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages