Inspection Detail
@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
@empty
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') }}
@endifCategory-wise questions & answers
@forelse($byCategory as $category => $answers){{ $category }}
No answers recorded for this inspection.
@endforelse