This package makes it easy to send Lark using the Laravel notification system. Supports 5.5+, 6.x, 7.x and 8.x.
You can install the package via composer:
composer require yajianguo/lark-notification-channel
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';
}
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.
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email a@a.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.