Files
SkinbaseNova/app/Notifications/StoryLikedNotification.php
2026-03-20 21:17:26 +01:00

46 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\Story;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class StoryLikedNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Story $story,
private readonly User $actor,
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'story_liked';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
return [
'type' => 'story_liked',
'story_id' => (int) $this->story->id,
'story_title' => $this->story->title,
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' liked your story',
'url' => route('stories.show', ['slug' => $this->story->slug]),
];
}
}