46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class FriendRequestNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public int $senderId;
|
|
public string $senderUsername;
|
|
public ?string $senderAvatar;
|
|
public int $friendRequestId;
|
|
|
|
public function __construct(int $senderId, string $senderUsername, ?string $senderAvatar, int $friendRequestId)
|
|
{
|
|
$this->senderId = $senderId;
|
|
$this->senderUsername = $senderUsername;
|
|
$this->senderAvatar = $senderAvatar;
|
|
$this->friendRequestId = $friendRequestId;
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'kind' => 'friend_request',
|
|
'icon' => 'user-plus',
|
|
'title' => 'Friend request',
|
|
'desc' => $this->senderUsername.' sent you a friend request',
|
|
'sender' => [
|
|
'id' => $this->senderId,
|
|
'username' => $this->senderUsername,
|
|
'avatar' => $this->senderAvatar,
|
|
],
|
|
'friend_request_id' => $this->friendRequestId,
|
|
];
|
|
}
|
|
}
|