@include('admin.include.header') @include('admin.include.sidebar')
@php $displayVehicle = $inspection->vehicle?->unit_number ?? $inspection->answers->first()?->vehicle_name ?? $inspection->answers->first()?->vehicle?->unit_number ?? '—'; $displayVin = $inspection->vehicle?->vin ?? $inspection->answers->first()?->vin ?? '—'; $displayDate = $inspection->inspection_date ? $inspection->inspection_date->format('M d, Y H:i') : ($inspection->answers->first()?->created_at?->format('M d, Y H:i') ?? '—'); // Per-question counts across all categories $allAnswers = $inspection->answers; $passCount = $allAnswers->where('status', 'pass')->count(); $fixCount = $allAnswers->where('status', 'fix')->count(); $failCount = $allAnswers->where('status', 'fail')->count(); $overallCount = $allAnswers->count(); @endphp

Vehicle: {{ $displayVehicle }}

VIN: {{ $displayVin }}

Inspection date: {{ $displayDate }}

@php $displayMechanic = null; foreach ($inspection->answers->sortByDesc('created_at') as $a) { $m = $a->mechanic; if ($m && $m->id != 1) { $displayMechanic = $m; break; } } if (!$displayMechanic && $inspection->mechanic && $inspection->mechanic->id != 1) $displayMechanic = $inspection->mechanic; @endphp

Mechanic: {{ $displayMechanic?->name ?? '—' }}

Overall questions: {{ $overallCount }}

Pass: {{ $passCount }} Fix: {{ $fixCount }} Fail: {{ $failCount }}

@if($inspection->due_date)

Due date: {{ $inspection->due_date->format('M d, Y') }}

@endif
Category-wise questions & answers
@forelse($byCategory as $category => $answers)
{{ $category }}
@foreach($answers as $a) @endforeach
Question Answer Notes Photos
{{ $a->question ?: '—' }} {{ ucfirst($a->status ?? '—') }} {{ $a->notes ?: '—' }} @php $answerImages = $a->images ?? collect(); @endphp @if($answerImages->isNotEmpty()) @foreach($answerImages as $img) Photo @endforeach @elseif(is_array($a->photo_paths) && count($a->photo_paths) > 0) @foreach($a->photo_paths as $path) Photo @endforeach @else — @endif
@empty

No answers recorded for this inspection.

@endforelse
@include('admin.include.footer')