@php $card = 'bg-white shadow-sm sm:rounded-lg p-6'; $h = 'text-sm font-semibold text-gray-500'; $inp = 'rounded-md border-gray-300 text-sm'; $userNames = \App\Models\User::pluck('name', 'id'); $clientNames = \App\Models\Client::pluck('name', 'id'); $fmt = function ($v, $field = '') use ($userNames, $clientNames) { if ($v === null || $v === '') return '—'; $v = (string) $v; if ($field === 'client_id') return $clientNames[$v] ?? "#$v"; if ($field === 'responsible_id') return $userNames[$v] ?? "#$v"; if ($field === 'status') return \App\Models\Order::STATUSES[$v] ?? $v; if (preg_match('/^(\d{4})-(\d{2})-(\d{2})( 00:00:00)?$/', $v, $m)) return "$m[3].$m[2].$m[1]"; return \Illuminate\Support\Str::limit($v, 80); }; $fresh = $history->filter(fn ($l) => $l->user_id !== auth()->id() && (! $lastSeen || $l->created_at->gt($lastSeen))); $related = $order->purchases->isNotEmpty() || $order->driverTasks->isNotEmpty(); @endphp
← Orders

{{ $order->client }} — {{ $order->title }}

{{-- Change the status right here, no need to open Edit --}} Edit
@if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ $errors->first() }}
@endif @if ($fresh->isNotEmpty()) {{ $fresh->count() }} change(s) by others since you last opened this order — see what changed ↓ @endif {{-- Details: full width, one line per field --}}
Quantity
{{ number_format($order->quantity) }}
Handover
{{ $order->handover_date->format('d.m.Y') }}
Responsible
{{ $order->responsible?->name ?? '—' }}
@if ($order->description)
Description
{{ $order->description }}
@endif
@if ($order->files->isNotEmpty())
@foreach ($order->files->sortBy(fn ($f) => $f->isImage() ? 0 : 1) as $f) @endforeach
@endif

Created by {{ $order->creator?->name ?? '—' }}, {{ $order->created_at->format('d.m.Y H:i') }} · last edited by {{ $order->editor?->name ?? '—' }}, {{ $order->updated_at->format('d.m.Y H:i') }}

{{-- Upload popup: choose, drop or paste --}}

Add files

{{-- Items: full width, one line per item --}}

Items

@if ($order->items->isNotEmpty())
    @foreach ($order->items as $item)
  • {{ $item->name }} @if ($item->description) — {{ $item->description }}@endif
    × {{ number_format($item->quantity) }}
    @csrf @method('DELETE')
  • @endforeach
@endif
@csrf
{{-- Notes --}}

Notes

@csrf
@if ($order->notes->isNotEmpty())
@foreach ($order->notes as $n)
{{ $n->body }}
{{ $n->user?->name ?? 'Unknown' }} · {{ $n->created_at->format('d.m.Y H:i') }}
@csrf @method('DELETE')
@endforeach
@endif
{{-- Related purchases and driver tasks: one quiet card --}}

Purchases and driver tasks

@if ($related) @endif
{{-- History: collapsed unless something new happened --}}
isNotEmpty()) open @endif> History ({{ $history->count() }}) @if ($fresh->isNotEmpty()){{ $fresh->count() }} new@endif
    @forelse ($history as $log) @php $isNew = $log->user_id !== auth()->id() && (! $lastSeen || $log->created_at->gt($lastSeen)); @endphp
  • {{ $log->user?->name ?? 'System' }} {{ ['created' => 'created', 'updated' => 'changed', 'deleted' => 'removed/archived'][$log->action] ?? $log->action }} · {{ $log->created_at->format('d.m.Y H:i') }} @if ($isNew)New@endif
    @if ($log->changes)
      @foreach ($log->changes as $field => $c)
    • {{ ucfirst(preg_replace('/ id$/', '', str_replace('_', ' ', $field))) }}: @if (($c['old'] ?? null) === null) + {{ $fmt($c['new'] ?? null, $field) }} @elseif (($c['new'] ?? null) === null) − {{ $fmt($c['old'], $field) }} @else {{ $fmt($c['old'], $field) }} → {{ $fmt($c['new'], $field) }} @endif
    • @endforeach
    @endif
  • @empty
  • No history yet.
  • @endforelse
@csrf @method('DELETE')