1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Notifications\TechTips; |
4
|
|
|
|
5
|
|
|
use App\Models\TechTip; |
6
|
|
|
use Illuminate\Bus\Queueable; |
7
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
8
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
9
|
|
|
use Illuminate\Notifications\Notification; |
10
|
|
|
|
11
|
|
|
class UpdatedTechTipNotification extends Notification |
12
|
|
|
{ |
13
|
|
|
use Queueable; |
14
|
|
|
|
15
|
|
|
protected $techTip; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Create a new notification instance. |
19
|
|
|
* |
20
|
|
|
* @return void |
21
|
|
|
*/ |
22
|
|
|
public function __construct(TechTip $techTip) |
23
|
|
|
{ |
24
|
|
|
$this->techTip = $techTip; |
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 ['mail', 'database']; |
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 MailMessage) |
47
|
|
|
->greeting('Updated Tech Tip') |
48
|
|
|
->line('Subject: '.$this->techTip->subject) |
49
|
|
|
->line('This Tech Tip has been updated with new information') |
50
|
|
|
->action('Click to View the Tech Tip', url(route('tech-tips.show', $this->techTip->slug))); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get the array representation of the notification. |
55
|
|
|
* |
56
|
|
|
* @param mixed $notifiable |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
public function toArray($notifiable) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
return [ |
62
|
|
|
'subject' => 'Updated Tech Tip', |
63
|
|
|
'data' => [ |
64
|
|
|
'tip_data' => $this->techTip, |
65
|
|
|
] |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.