44 lines
1.6 KiB
PHP
44 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 TaskAssignedNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(protected ServiceTask $serviceTask)
|
|
{
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database', 'mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): array|MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->subject('Nouvelle tâche d\'intégration assignée')
|
|
->line('Une nouvelle tâche d\'intégration pour l\'agent ' . $this->serviceTask->integrationRequest->agent->first_name . ' ' . $notifiable->name . ' a été assignée à votre service.')
|
|
->action('Voir la tâche', route('integrations.show', $this->serviceTask->integrationRequest))
|
|
->line('Merci de traiter cette demande dans les plus brefs délais.');
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'service_task_id' => $this->serviceTask->id,
|
|
'integration_request_id' => $this->serviceTask->integration_request_id,
|
|
'service_name' => $this->serviceTask->service->name,
|
|
'agent_name' => $this->serviceTask->integrationRequest->agent->first_name . ' ' . $this->serviceTask->integrationRequest->agent->last_name,
|
|
'message' => 'Nouvelle tâche assignée',
|
|
];
|
|
}
|
|
}
|