{{-- resources/views/damages/index.blade.php --}} @php $vehicle = app(\App\Support\VehicleContext::class)->current(); $title = ($vehicle?->call_sign ?? 'RTW') . ' – Schäden'; $pageTitle = 'Schäden'; $pageSubtitle = 'Schäden melden und Status verfolgen. Kritische Schäden können den RTW auf „Nicht einsatzbereit“ setzen.'; $tab = $filters['tab'] ?? 'active'; $status = $filters['status'] ?? 'all'; $tabBtn = fn(bool $active) => $active ? 'bg-brand/10 text-brand' : 'text-gray-700 hover:bg-gray-50'; $statusBadge = function (int $s): array { return match ($s) { \App\Models\Damage::STATUS_OPEN => ['Offen', 'bg-red-50 text-red-700 ring-red-200'], \App\Models\Damage::STATUS_IN_PROGRESS => [ 'In Bearbeitung', 'bg-yellow-50 text-yellow-800 ring-yellow-200', ], \App\Models\Damage::STATUS_RESOLVED => ['Erledigt', 'bg-gray-100 text-gray-700 ring-gray-200'], default => ['Status', 'bg-gray-100 text-gray-700 ring-gray-200'], }; }; $urgencyBadge = function (?int $u): array { $u = (int) ($u ?? \App\Models\Damage::URGENCY_MEDIUM); return match ($u) { \App\Models\Damage::URGENCY_CRITICAL => ['Kritisch', 'bg-red-50 text-red-700 ring-red-200'], \App\Models\Damage::URGENCY_MEDIUM => ['Mittel', 'bg-yellow-50 text-yellow-800 ring-yellow-200'], \App\Models\Damage::URGENCY_LOW => ['Gering', 'bg-gray-100 text-gray-700 ring-gray-200'], default => ['—', 'bg-gray-100 text-gray-700 ring-gray-200'], }; }; $urgency = (string) ($filters['urgency'] ?? request('urgency', 'all')); // all|critical|medium|low @endphp
{{-- Desktop Toolbar --}} {{-- Mobile Toolbar --}}
Filter
{{ $tab === 'active' ? 'Aktiv' : 'Erledigt' }} • {{ $status === 'all' ? 'Status: Alle' : ($status === 'open' ? 'Status: Offen' : ($status === 'in_progress' ? 'Status: In Bearbeitung' : 'Status: Erledigt')) }} @if ($urgency !== 'all') • {{ $urgency === 'critical' ? 'Kritisch' : ($urgency === 'medium' ? 'Mittel' : 'Gering') }} @endif
Schaden hinzufügen
{{-- Mobile Filter Modal --}} {{-- Mobile Cards --}}
@forelse($damages as $d) @php [$sLabel, $sCls] = $statusBadge((int) $d->status); [$uLabel, $uCls] = $urgencyBadge($d->urgency); $date = $d->occurred_at?->format('d.m.Y') ?? ($d->reported_at?->format('d.m.Y') ?? ($d->created_at?->format('d.m.Y') ?? '—')); $next = null; if (auth()->user()?->can('update', $d)) { $next = match ((int) $d->status) { \App\Models\Damage::STATUS_OPEN => [ 'label' => 'In Bearbeitung', 'to' => \App\Models\Damage::STATUS_IN_PROGRESS, ], \App\Models\Damage::STATUS_IN_PROGRESS => [ 'label' => 'Erledigt', 'to' => \App\Models\Damage::STATUS_RESOLVED, ], default => null, }; } @endphp
{{ $d->title }}
{{ $date }} • Maßnahmen: {{ (int) $d->measures_count }} • Anhänge: {{ (int) $d->attachments_count }}
{{ $sLabel }} {{ $uLabel }}
@can('update', $d) @if ($next)
@csrf @method('PATCH')
@endif Bearbeiten @endcan Details
@empty
Keine Schäden vorhanden.
@endforelse
{{-- Desktop Table --}}
UX-Regel: „Kritisch“ + „Einsatzrelevant“ ⇒ Status kann automatisch auf „Nicht einsatzbereit“ wechseln.
{{ $damages->links() }}