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