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