61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Dto\OrderReminderDto;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
// NOTE: ! This has to be queued !
|
|
class OrderTodayReminderNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/** 'failed_jobs' after */
|
|
public int $tries = 5;
|
|
|
|
/**
|
|
* Attempts delays
|
|
*
|
|
* @return array<int, int>
|
|
*/
|
|
public function backoff(): array
|
|
{
|
|
return [10, 30, 60, 300];
|
|
}
|
|
|
|
public function __construct(
|
|
private readonly OrderReminderDto $dto
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(mixed $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*/
|
|
public function toMail(mixed $notifiable): MailMessage
|
|
{
|
|
return new MailMessage()
|
|
->subject(trans('You have an order to collect today - :appname', [
|
|
'appname' => config()->string('app.name'),
|
|
]))
|
|
->markdown('emails.order-reminder', [
|
|
'dto' => $this->dto,
|
|
]);
|
|
}
|
|
}
|