ldc-gen-game-web/app/Notifications/Customer/HasWonDiscount.php

67 lines
1.7 KiB
PHP
Raw Normal View History

2023-12-12 14:56:12 +01:00
<?php
namespace App\Notifications\Customer;
2025-10-27 16:23:02 +01:00
use App\Lib\Discount;
2023-12-12 14:56:12 +01:00
use App\Mail\Won\DiscountWonMail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Notifications\Notification;
class HasWonDiscount extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*
* @param \App\Lib\Discount $discount The discount as set in Settings.
* @param string $first_name The client first name.
2023-12-12 14:56:12 +01:00
* @return void
*/
public function __construct(
2025-10-27 16:23:02 +01:00
protected Discount $discount,
2023-12-12 14:56:12 +01:00
protected string $first_name
) {
// Keep empty.
}
2023-12-12 14:56:12 +01:00
/**
* Get the notification's delivery channels.
*
* @param object $notifiable
* @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.
*
* @param object $notifiable
2023-12-12 14:56:12 +01:00
* @return \Illuminate\Contracts\Mail\Mailable
*/
public function toMail(object $notifiable): Mailable
2023-12-12 14:56:12 +01:00
{
/** @var \App\Models\Settings */
$settings = \tenant()->setting;
/** @var \App\Models\Customer $notifiable */
2023-12-12 14:56:12 +01:00
return (new DiscountWonMail(
new Address(
$notifiable->email,
$this->first_name
),
$settings->name,
$this->discount,
2025-10-27 16:23:02 +01:00
route('fo.view-winning-participations'),
$settings->company,
2023-12-12 14:56:12 +01:00
));
}
}