82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace App\Notifications;
|
||
|
||
use App\Channels\WechatMiniChannel;
|
||
use Illuminate\Bus\Queueable;
|
||
use Illuminate\Notifications\Channels\DatabaseChannel;
|
||
use Illuminate\Notifications\Notification;
|
||
use Modules\User\Models\IdentityMiddle;
|
||
use Modules\User\Models\User;
|
||
|
||
class SystemUpdateCase extends Notification
|
||
{
|
||
|
||
use Queueable;
|
||
|
||
protected $content;
|
||
protected $title;
|
||
protected $url;
|
||
|
||
/**
|
||
* Create a new notification instance.
|
||
*
|
||
* @return void
|
||
*/
|
||
public function __construct()
|
||
{
|
||
$this->title = '上传报告提醒';
|
||
$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' => '3sksrHdMTu3k1yderqyP5hOYXWltNf-CvESRG4r3Fnc',
|
||
'url' => $this->url,
|
||
'data' => [
|
||
'first' => $this->title,
|
||
'keyword1' => now(),
|
||
'keyword2' => '您已经连续打卡30天,请上传报告',
|
||
'remark' => '',
|
||
],
|
||
]);
|
||
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 发送到数据库
|
||
*
|
||
* @param mixed $notifiable
|
||
* @return array
|
||
*/
|
||
public function toDatabase(User $notifiable): array
|
||
{
|
||
return [
|
||
'title' => $this->title,
|
||
'content' => '您已经连续打卡30天,请上传报告',
|
||
'url' => $this->url,
|
||
];
|
||
}
|
||
}
|