update
This commit is contained in:
49
app/Notifications/StoryCommentedNotification.php
Normal file
49
app/Notifications/StoryCommentedNotification.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Story;
|
||||
use App\Models\StoryComment;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class StoryCommentedNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly Story $story,
|
||||
private readonly StoryComment $comment,
|
||||
private readonly User $actor,
|
||||
) {}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
public function databaseType(object $notifiable): string
|
||||
{
|
||||
return 'story_commented';
|
||||
}
|
||||
|
||||
public function toDatabase(object $notifiable): array
|
||||
{
|
||||
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
|
||||
|
||||
return [
|
||||
'type' => 'story_commented',
|
||||
'story_id' => (int) $this->story->id,
|
||||
'story_title' => $this->story->title,
|
||||
'comment_id' => (int) $this->comment->id,
|
||||
'actor_id' => (int) $this->actor->id,
|
||||
'actor_name' => $this->actor->name,
|
||||
'actor_username' => $this->actor->username,
|
||||
'message' => $label . ' commented on your story',
|
||||
'url' => route('stories.show', ['slug' => $this->story->slug]) . '#story-comment-' . $this->comment->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user