update
This commit is contained in:
40
app/Notifications/UserFollowedNotification.php
Normal file
40
app/Notifications/UserFollowedNotification.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user