hasAnyRole(['travel_approver', 'administrator']), 403); $this->travelRequest = TravelRequest::with([ 'user', 'journeys', 'costCodes', 'approvals.step', 'approvals.approver', ])->findOrFail($id); $this->pendingApproval = $this->travelRequest->approvals() ->where('status', \App\Enums\ApprovalStatus::Pending->value) ->with('step') ->first(); } public function approve(): void { abort_unless($this->pendingApproval, 403); app(ApprovalService::class)->approve($this->pendingApproval, Auth::user(), $this->comments ?: null); session()->flash('success', 'Request approved successfully.'); $this->redirect(route('dashboard'), navigate: true); } public function reject(): void { $this->validate(['comments' => ['required', 'string', 'min:5']], [ 'comments.required' => 'Please provide a reason for rejection.', 'comments.min' => 'Rejection reason must be at least 5 characters.', ]); abort_unless($this->pendingApproval, 403); app(ApprovalService::class)->reject($this->pendingApproval, Auth::user(), $this->comments); session()->flash('success', 'Request rejected.'); $this->redirect(route('dashboard'), navigate: true); } public function render(): mixed { return view('livewire.travel-request.approve'); } } ?>

Review Travel Request #{{ $travelRequest->id }}

Back
@if (! $pendingApproval)
This request has no pending approval steps.
@else
Step {{ $pendingApproval->step->order }}: {{ $pendingApproval->step->name }} — Awaiting your review.
@endif {{-- Request Summary --}}
Request Summary
Applicant
{{ $travelRequest->user->name }} ({{ $travelRequest->user->email }})
Reason
{{ $travelRequest->reason_summary }}
Journeys
@foreach ($travelRequest->journeys as $journey)
{{ $journey->origin }} → {{ $journey->destination }} on {{ $journey->date->format('d M Y') }} ({{ $journey->method->label() }})
@endforeach
Accommodation
{{ $travelRequest->needs_accommodation ? 'Required' : 'Not required' }}
Car Hire
{{ $travelRequest->needs_car_hire ? 'Required' : 'Not required' }}
Business Days
{{ $travelRequest->business_days }}
@if ($pendingApproval) {{-- Approve/Reject Form --}}
Decision
@error('comments')
{{ $message }}
@enderror
@endif