-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathExpectedCheckinNotification.php
More file actions
74 lines (62 loc) · 2.04 KB
/
Copy pathExpectedCheckinNotification.php
File metadata and controls
74 lines (62 loc) · 2.04 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
65
66
67
68
69
70
71
72
73
74
<?php
namespace App\Notifications;
use App\Helpers\Helper;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Symfony\Component\Mime\Email;
#[AllowDynamicProperties]
class ExpectedCheckinNotification extends Notification implements ShouldQueue
{
use Queueable;
private $params;
/**
* Create a new notification instance.
*/
public function __construct($params)
{
$this->params = $params;
}
/**
* Get the notification's delivery channels.
*
* @return array
*/
public function via()
{
$notifyBy = [];
$item = $this->params['item'];
$notifyBy[] = 'mail';
return $notifyBy;
}
/**
* Get the mail representation of the notification.
*
* @return MailMessage
*/
public function toMail()
{
$today = Carbon::today();
$expected = Carbon::parse($this->params->expected_checkin)->startOfDay();
$subjectText = $today->greaterThan($expected)
? trans('mail.Expected_Checkin_Notification_Pastdue', ['name' => $this->params->display_name])
: trans('mail.Expected_Checkin_Notification', ['name' => $this->params->display_name]);
$message = (new MailMessage)->markdown('notifications.markdown.expected-checkin',
[
'expected_checkin_date' => $this->params->expected_checkin,
'date' => Helper::getFormattedDateObject($this->params->expected_checkin, 'date', false),
'asset' => $this->params->display_name,
'serial' => $this->params->serial,
'asset_tag' => $this->params->asset_tag,
])
->subject('⏰'.$subjectText)
->withSymfonyMessage(function (Email $message) {
$message->getHeaders()->addTextHeader(
'X-System-Sender', 'Snipe-IT'
);
});
return $message;
}
}