|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Announcement\Notifications; |
|
4
|
|
|
|
|
5
|
|
|
use Adminetic\Announcement\Mail\AnnouncementMail; |
|
6
|
|
|
use Adminetic\Announcement\Models\Admin\Announcement; |
|
7
|
|
|
use Illuminate\Bus\Queueable; |
|
8
|
|
|
use Illuminate\Notifications\Messages\SlackMessage; |
|
9
|
|
|
use Illuminate\Notifications\Notification; |
|
10
|
|
|
|
|
11
|
|
|
class AnnouncementNotification extends Notification |
|
12
|
|
|
{ |
|
13
|
|
|
use Queueable; |
|
14
|
|
|
|
|
15
|
|
|
protected $announcement; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Create a new notification instance. |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct(Announcement $announcement) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->announcement = $announcement; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Get the notification's delivery channels. |
|
29
|
|
|
* |
|
30
|
|
|
* @param mixed $notifiable |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
|
public function via($notifiable) |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
return $this->announcement->mediums(); |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Get the mail representation of the notification. |
|
40
|
|
|
* |
|
41
|
|
|
* @param mixed $notifiable |
|
42
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
43
|
|
|
*/ |
|
44
|
|
|
public function toMail($notifiable) |
|
45
|
|
|
{ |
|
46
|
|
|
return (new AnnouncementMail($this->announcement)) |
|
|
|
|
|
|
47
|
|
|
->to($notifiable->email); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get the array representation of the notification. |
|
52
|
|
|
* |
|
53
|
|
|
* @param mixed $notifiable |
|
54
|
|
|
* @return array |
|
55
|
|
|
*/ |
|
56
|
|
|
public function toArray($notifiable) |
|
|
|
|
|
|
57
|
|
|
{ |
|
58
|
|
|
return [ |
|
59
|
|
|
'model' => 'announcement', |
|
60
|
|
|
'id' => $this->announcement->id, |
|
61
|
|
|
'date_time' => $this->announcement->created_at->diffForHumans(), |
|
|
|
|
|
|
62
|
|
|
'announcement_by' => $this->announcement->user->name ?? 'N/A', |
|
63
|
|
|
'announcement' => $this->announcement->body, |
|
64
|
|
|
]; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.