title = '喝水打卡提醒'; $this->content = '您今天还没有喝水打卡,请前去打卡'; $this->url = config('user.web.base'); } public function via(): array { return [DatabaseChannel::class, WechatMiniChannel::class]; } /** * Notes: 喝水打卡提醒 * * @Author: 玄尘 * @Date: 2022/8/8 8:48 * @param User $notifiable * @return bool */ public function toWeChat(User $notifiable): bool { if ($notifiable->isOfficialSubscribe()) { $app = app('wechat.official_account'); $app->template_message->send([ 'touser' => $notifiable->wechat->official_openid, 'template_id' => 'N7-vo1bSYXahw22pplkHtI7WGg96dPf1KdMxbKdx6ao', 'url' => $this->url, 'data' => [ 'first' => $this->title, 'keyword1' => now(), 'keyword2' => $this->content, 'remark' => '', ], ]); } return true; } /** * 发送到数据库 * * @param mixed $notifiable * @return array */ public function toDatabase(User $notifiable): array { return [ 'title' => $this->title, 'content' => $this->content, 'url' => $this->url, ]; } }