feat: Initialize core application structure including authentication, role-based dashboards, service task management, and integration workflows.
This commit is contained in:
51
app/Notifications/ServiceTaskRejectedNotification.php
Normal file
51
app/Notifications/ServiceTaskRejectedNotification.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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 ServiceTaskRejectedNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(public ServiceTask $serviceTask, public string $reason)
|
||||
{
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database', 'mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$agentName = $this->serviceTask->data['agent_name'] ?? 'Agent';
|
||||
// Try to fetch agent name if avail
|
||||
if ($this->serviceTask->integrationRequest && $this->serviceTask->integrationRequest->agent) {
|
||||
$agentName = $this->serviceTask->integrationRequest->agent->first_name . ' ' . $this->serviceTask->integrationRequest->agent->last_name;
|
||||
}
|
||||
|
||||
return (new MailMessage)
|
||||
->error()
|
||||
->subject("Tâche REJETÉE : {$agentName}")
|
||||
->greeting("Bonjour {$notifiable->name},")
|
||||
->line("La tâche pour l'agent **{$agentName}** a été rejetée.")
|
||||
->line("**Raison du rejet :** {$this->reason}")
|
||||
->action('Voir la tâche', route('integrations.show', $this->serviceTask->integrationRequest))
|
||||
->line('Merci de corriger les éléments nécessaires puis de valider à nouveau.');
|
||||
}
|
||||
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'service_task_id' => $this->serviceTask->id,
|
||||
'integration_request_id' => $this->serviceTask->integration_request_id,
|
||||
'message' => "La tâche a été rejetée. Motif : {$this->reason}",
|
||||
'type' => 'task_rejected',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user