47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\ServiceTask;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class ServiceTaskValidatedNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(public ServiceTask $serviceTask)
|
|
{
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database', 'mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$agentName = $this->serviceTask->integrationRequest->agent->first_name . ' ' . $this->serviceTask->integrationRequest->agent->last_name;
|
|
$serviceName = $this->serviceTask->service->name;
|
|
|
|
return (new MailMessage)
|
|
->subject("Tâche validée : {$serviceName} - {$agentName}")
|
|
->greeting("Bonjour {$notifiable->name},")
|
|
->line("Le service **{$serviceName}** a validé sa tâche pour l'agent **{$agentName}**.")
|
|
->action('Voir la demande', route('integrations.show', $this->serviceTask->integrationRequest))
|
|
->line('Merci d\'utiliser notre application.');
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'service_task_id' => $this->serviceTask->id,
|
|
'integration_request_id' => $this->serviceTask->integration_request_id,
|
|
'message' => "Le service {$this->serviceTask->service->name} a validé sa tâche.",
|
|
'type' => 'task_validated',
|
|
];
|
|
}
|
|
}
|