ldc-gen-game-web/app/Notifications/Customer/HasWonInstantWin.php
2026-10-20 12:27:49 +02:00

65 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Notifications\Customer;
use App\Mail\Won\PrizeWonMail;
use App\Models\Customer;
use App\Models\Prize;
use App\Models\Settings;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Notifications\Notification;
class HasWonInstantWin extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*
* @param Prize $prize The prize that has been won.
* @param string $first_name The client first name.
*/
public function __construct(protected Prize $prize, protected string $first_name)
{
$this->prize = $prize->withoutRelations();
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function via(object $notifiable): array
{
// phpcs:enable
return ['mail'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): Mailable
{
/** @var Settings */
$settings = resolve(Settings::class);
/** @var Customer $notifiable */
return new PrizeWonMail(
new Address(
$notifiable->email,
$this->first_name
),
$settings->name,
$this->prize,
config('app.url'),
$settings->company,
);
}
}