42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\ServiceRequest;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class SlaWarningNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(private readonly ServiceRequest $request)
|
|
{
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database', 'mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->subject('SLA предупреждение')
|
|
->line("До дедлайна заявки {$this->request->ticket_number} осталось менее часа.")
|
|
->action('Открыть заявку', route('requests.show', $this->request));
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'title' => 'Предупреждение SLA',
|
|
'message' => "До дедлайна заявки {$this->request->ticket_number} осталось менее часа",
|
|
'request_id' => $this->request->id,
|
|
'url' => route('requests.show', $this->request),
|
|
];
|
|
}
|
|
}
|