|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Notifications; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Bus\Queueable; |
|
6
|
|
|
use Illuminate\Notifications\Notification; |
|
7
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
8
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
|
9
|
|
|
|
|
10
|
|
|
class NewTechTip extends Notification implements ShouldQueue |
|
11
|
|
|
{ |
|
12
|
|
|
use Queueable; |
|
13
|
|
|
protected $details; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Create a new notification instance. |
|
17
|
|
|
* |
|
18
|
|
|
* @return void |
|
19
|
|
|
*/ |
|
20
|
4 |
|
public function __construct($details) |
|
21
|
|
|
{ |
|
22
|
|
|
// |
|
23
|
4 |
|
$this->details = $details; |
|
24
|
4 |
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Get the notification's delivery channels. |
|
28
|
|
|
* |
|
29
|
|
|
* @param mixed $notifiable |
|
30
|
|
|
* @return array |
|
31
|
|
|
*/ |
|
32
|
4 |
|
public function via($notifiable) |
|
33
|
|
|
{ |
|
34
|
4 |
|
return ['mail', 'database']; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get the mail representation of the notification. |
|
39
|
|
|
* |
|
40
|
|
|
* @param mixed $notifiable |
|
41
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
42
|
|
|
*/ |
|
43
|
|
|
public function toMail($notifiable) |
|
44
|
|
|
{ |
|
45
|
|
|
return (new MailMessage) |
|
46
|
|
|
->line('A new Tech Tip has been created') |
|
47
|
|
|
->line('Subject: '.$this->details->subject) |
|
48
|
|
|
->action('Click to view Tech Tip', url(route('tip.details', ['id' => $this->details->tip_id, 'name' => urlencode($this->details->subject)]))); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get the array representation of the notification. |
|
53
|
|
|
* |
|
54
|
|
|
* @param mixed $notifiable |
|
55
|
|
|
* @return array |
|
56
|
|
|
*/ |
|
57
|
|
|
public function toArray($notifiable) |
|
58
|
|
|
{ |
|
59
|
|
|
return [ |
|
60
|
|
|
// |
|
61
|
|
|
'type' => 'warning', |
|
62
|
|
|
'message' => 'New Tech Tip Created - '.$this->details->subject, |
|
63
|
|
|
'link' => url(route( |
|
64
|
|
|
'tip.details', |
|
65
|
|
|
[ |
|
66
|
|
|
'id' => $this->details->tip_id, |
|
67
|
|
|
'name' => urlencode($this->details->subject) |
|
68
|
|
|
] |
|
69
|
|
|
)) |
|
70
|
|
|
]; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|