UserCertifyApplyNotification.php
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace App\Notifications;
use App\Models\User;
use App\Models\UserCertify;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
class UserCertifyApplyNotification extends Notification implements ShouldQueue
{
use Queueable;
public UserCertify $userCertify;
public User $applyUser;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(UserCertify $userCertify)
{
$this->userCertify = $userCertify;
$this->applyUser = $userCertify->getAttribute('user');
}
/**
* Get the notification's delivery channels.
*
* @return array
*/
public function via(): array
{
return ['wechat', 'jPush'];
}
public function toJPush(User $notifiable): array
{
return [
'user' => $notifiable->getKey(),
'title' => $this->applyUser->getAttribute('nick_name') . '提交了认证申请',
'content' => '点击查看详情',
'data' => ['type' => 'userAuth', 'value' => '']
];
}
public function toWechat(User $notifiable): array
{
return [
'openId' => $notifiable->getAttribute('official_id'),
'template' => 'DWu2Opezt2ricor_x38tq-PWna8k26ehJbhRbNwua4c',
'data' => [
'keyword1' => $this->applyUser->getAttribute('nick_name'),
'keyword2' => (string)$this->userCertify->getAttribute('created_at'),
'keyword3' => '无',
],
"page" => '/packageLogin/pages/applyList'
];
}
}