|
|
<?php
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
class AuditEmailNotify extends Notification
|
|
|
{
|
|
|
use Queueable;
|
|
|
|
|
|
protected $visitData;
|
|
|
protected $isFirstAudit;
|
|
|
|
|
|
/**
|
|
|
* Create a new notification instance.
|
|
|
*
|
|
|
* @param array $visitData
|
|
|
* @param bool $isFirstAudit
|
|
|
*/
|
|
|
public function __construct($visitData, $isFirstAudit = false)
|
|
|
{
|
|
|
$this->visitData = $visitData;
|
|
|
$this->isFirstAudit = $isFirstAudit;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the notification's delivery channels.
|
|
|
*
|
|
|
* @param mixed $notifiable
|
|
|
* @return array
|
|
|
*/
|
|
|
public function via($notifiable)
|
|
|
{
|
|
|
return ['mail'];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the mail representation of the notification.
|
|
|
*
|
|
|
* @param mixed $notifiable
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
|
*/
|
|
|
public function toMail($notifiable)
|
|
|
{
|
|
|
$visitData = $this->visitData;
|
|
|
|
|
|
if ($this->isFirstAudit) {
|
|
|
// 第一个审核人的邮件
|
|
|
return (new MailMessage)
|
|
|
->from(config('mail.from.address'), 'Getinge Suzhou HR')
|
|
|
->subject('新的拜访审核通知 - ' . $visitData['name'])
|
|
|
->greeting('您好 ' . $notifiable->name . ',')
|
|
|
->line('您有一个新的拜访申请需要审核,访客 ' . $visitData['name'] . ' 预约于 ' . $visitData['date'] . ' 到访。')
|
|
|
->line('访客联系电话:' . $visitData['mobile'])
|
|
|
->line('拜访事由:' . ($visitData['reason'] ?? '无'))
|
|
|
->line('请及时审核此拜访申请。')
|
|
|
->salutation('')
|
|
|
->line('Regards')
|
|
|
->line('Getinge Suzhou HR');
|
|
|
} else {
|
|
|
// 后续审核人的邮件
|
|
|
return (new MailMessage)
|
|
|
->from(config('mail.from.address'), 'Getinge Suzhou HR')
|
|
|
->subject('拜访审核流转通知 - ' . $visitData['name'])
|
|
|
->greeting('您好 ' . $notifiable->name . ',')
|
|
|
->line('拜访申请 ' . $visitData['name'] . ' 预约于 ' . $visitData['date'] . ' 的审核已流转到您这里,上一级审核人:' . ($visitData['previous_admin'] ?? '') . '。')
|
|
|
->line('访客联系电话:' . $visitData['mobile'])
|
|
|
->line('拜访事由:' . ($visitData['reason'] ?? '无'))
|
|
|
->line('请及时处理此审核流转。')
|
|
|
->salutation('')
|
|
|
->line('Regards')
|
|
|
->line('Getinge Suzhou HR');
|
|
|
}
|
|
|
}
|
|
|
}
|