feat: complete approval workflow

This commit is contained in:
2026-08-04 16:51:51 +01:00
parent c2136bc250
commit 809eab9d4a
26 changed files with 1156 additions and 41 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Notifications;
use App\Domain\Reservations\Models\Reservation;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class ReservationSubmittedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
public readonly Reservation $reservation,
public readonly string $event = 'submitted',
) {
$this->afterCommit();
}
/** @return list<string> */
public function via(object $notifiable): array
{
return ['mail', 'database'];
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->subject($this->event === 'information_provided'
? "Resposta recebida para {$this->reservation->reference}"
: "Nova requisição {$this->reservation->reference}")
->greeting($this->event === 'information_provided'
? 'O requisitante respondeu ao pedido de esclarecimentos'
: 'Nova requisição para aprovação')
->line("{$this->reservation->requester->name} submeteu a requisição {$this->reservation->reference} para decisão.")
->line("Período: {$this->reservation->starts_at->format('d/m/Y H:i')} — {$this->reservation->ends_at->format('d/m/Y H:i')}.")
->action('Analisar requisição', url('/aprovacoes'));
}
/** @return array<string, mixed> */
public function toArray(object $notifiable): array
{
return [
'reservation_uuid' => $this->reservation->uuid,
'reference' => $this->reservation->reference,
'event' => $this->event,
'message' => $this->event === 'information_provided'
? "Foram prestados esclarecimentos para {$this->reservation->reference}."
: "Nova requisição {$this->reservation->reference} aguarda decisão.",
'url' => '/aprovacoes',
];
}
}