46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Post;
|
|
use App\Models\PostComment;
|
|
use App\Models\User;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class PostCommentedNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
public readonly Post $post,
|
|
public readonly PostComment $comment,
|
|
public readonly User $commenter,
|
|
) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function databaseType(object $notifiable): string
|
|
{
|
|
return 'post_commented';
|
|
}
|
|
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'post_commented',
|
|
'post_id' => $this->post->id,
|
|
'comment_id' => $this->comment->id,
|
|
'commenter_id' => $this->commenter->id,
|
|
'commenter_name' => $this->commenter->name,
|
|
'commenter_username' => $this->commenter->username,
|
|
'message' => "{$this->commenter->name} commented on your post",
|
|
'url' => "/@{$this->post->user->username}/posts",
|
|
];
|
|
}
|
|
}
|