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

40 lines
1010 B
PHP

<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class UserFollowedNotification extends Notification
{
use Queueable;
public function __construct(private readonly User $actor) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function databaseType(object $notifiable): string
{
return 'user_followed';
}
public function toDatabase(object $notifiable): array
{
$label = $this->actor->name ?: $this->actor->username ?: 'Someone';
return [
'type' => 'user_followed',
'actor_id' => (int) $this->actor->id,
'actor_name' => $this->actor->name,
'actor_username' => $this->actor->username,
'message' => $label . ' started following you',
'url' => $this->actor->username ? '/@' . $this->actor->username : null,
];
}
}