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()
->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.
This method needs to return the URL where the notification Lark will receive a POST request.
public function routeNotificationForLark()
{
return 'http://requestb.in/1234x';
}
Available methods
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 [email protected] 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.