1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Notifications; |
4
|
|
|
|
5
|
|
|
use App\Models\TechTip; |
6
|
|
|
use App\Models\TechTipComment; |
7
|
|
|
use App\Models\User; |
8
|
|
|
use Illuminate\Bus\Queueable; |
9
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
10
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
11
|
|
|
use Illuminate\Notifications\Notification; |
12
|
|
|
|
13
|
|
|
class NewTechTipCommentNotification extends Notification |
14
|
|
|
{ |
15
|
|
|
use Queueable; |
16
|
|
|
|
17
|
|
|
protected $comment; |
18
|
|
|
protected $user; |
19
|
|
|
protected $tip; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Create a new notification instance |
23
|
|
|
*/ |
24
|
|
|
public function __construct(TechTipComment $comment, User $user) |
25
|
|
|
{ |
26
|
|
|
$this->comment = $comment; |
27
|
|
|
$this->user = $user; |
28
|
|
|
$this->tip = TechTip::find($comment->tip_id); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Get the notification's delivery channels |
33
|
|
|
*/ |
34
|
|
|
public function via($notifiable) |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
return ['mail', 'database']; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get the mail representation of the notification |
41
|
|
|
*/ |
42
|
|
|
public function toMail($notifiable) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
return (new MailMessage) |
45
|
|
|
->greeting('Hello') |
46
|
|
|
->line($this->user->full_name.' has commented on Tech Tip - .'.$this->tip->subject) |
47
|
|
|
->line('The comment is: ') |
48
|
|
|
->line($this->comment->comment) |
49
|
|
|
->action('Click Here to review the comment', url(route('tech-tips.show', $this->tip->slug))); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get the array representation of the notification. |
54
|
|
|
* |
55
|
|
|
* @param mixed $notifiable |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function toArray($notifiable) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
return [ |
61
|
|
|
'subject' => 'New Tech Tip Comment', |
62
|
|
|
'data' => [ |
63
|
|
|
'tip' => $this->tip, |
64
|
|
|
'comment' => $this->comment, |
65
|
|
|
'user' => $this->user, |
66
|
|
|
], |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.