|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Usamamuneerchaudhary\Commentify\Notifications; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Bus\Queueable; |
|
6
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
7
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
|
8
|
|
|
use Illuminate\Notifications\Notification; |
|
9
|
|
|
use Usamamuneerchaudhary\Commentify\Events\CommentLiked; |
|
10
|
|
|
|
|
11
|
|
|
class CommentLikedNotification extends Notification implements ShouldQueue |
|
12
|
|
|
{ |
|
13
|
|
|
use Queueable; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Create a new notification instance. |
|
17
|
|
|
*/ |
|
18
|
|
|
public function __construct( |
|
19
|
|
|
public CommentLiked $event |
|
20
|
|
|
) { |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Get the notification's delivery channels. |
|
25
|
|
|
* |
|
26
|
|
|
* @return array<int, string> |
|
27
|
|
|
*/ |
|
28
|
|
|
public function via(object $notifiable): array |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
$channels = config('commentify.notification_channels', ['database']); |
|
31
|
|
|
|
|
32
|
|
|
return array_filter($channels, function ($channel) { |
|
33
|
|
|
return in_array($channel, ['database', 'mail', 'broadcast']); |
|
34
|
|
|
}); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get the mail representation of the notification. |
|
39
|
|
|
*/ |
|
40
|
|
|
public function toMail(object $notifiable): MailMessage |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
|
|
return (new MailMessage) |
|
43
|
|
|
->subject(__('commentify::commentify.notifications.comment_liked_subject')) |
|
44
|
|
|
->line(__('commentify::commentify.notifications.comment_liked_line')) |
|
45
|
|
|
->action( |
|
46
|
|
|
__('commentify::commentify.notifications.view_comment'), |
|
47
|
|
|
url('/comments/' . $this->event->comment->id) |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get the array representation of the notification. |
|
53
|
|
|
* |
|
54
|
|
|
* @return array<string, mixed> |
|
55
|
|
|
*/ |
|
56
|
|
|
public function toArray(object $notifiable): array |
|
|
|
|
|
|
57
|
|
|
{ |
|
58
|
|
|
return [ |
|
59
|
|
|
'comment_id' => $this->event->comment->id, |
|
60
|
|
|
'user_id' => $this->event->userId, |
|
61
|
|
|
'message' => __('commentify::commentify.notifications.comment_liked_message'), |
|
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.