41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Achievement;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class AchievementUnlockedNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(private readonly Achievement $achievement) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function databaseType(object $notifiable): string
|
|
{
|
|
return 'achievement_unlocked';
|
|
}
|
|
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'achievement_unlocked',
|
|
'achievement_id' => $this->achievement->id,
|
|
'achievement_slug' => $this->achievement->slug,
|
|
'title' => $this->achievement->name,
|
|
'icon' => $this->achievement->icon,
|
|
'message' => '🎉 You unlocked: ' . $this->achievement->name,
|
|
'xp_reward' => (int) $this->achievement->xp_reward,
|
|
'url' => '/dashboard?panel=achievements',
|
|
];
|
|
}
|
|
}
|