钉钉Notification模板生成
php artisan extend
命令可以帮助您生成钉钉 Notification
,
选择代码生成器 【4】,在选择【0】 即可生成 DingtalkRobotNotification
在项目的 Notifications
目录中可以看到 DingtalkRobotNotification
具体代码为:
<?php
namespace App\Notifications;
use Chowjiawei\Helpers\Channels\DingtalkRobotChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class DingtalkRobotNotification extends Notification
{
use Queueable;
public function __construct($text)
{
$this->text=$text;
}
public function via($notifiable)
{
return [DingtalkRobotChannel::class];
}
public function toDingtalkRobot($notifiable)
{
return $this->text;
}
}
使用方法为:
Notification::route('dingtalk_robot', config('helpers.dingtalk'))
->notify(new DingtalkRobotNotification($message, "通知"));
推荐文章: