@php $card = 'bg-white shadow-sm sm:rounded-lg p-6'; $h = 'text-sm font-semibold uppercase tracking-wide text-gray-500'; $fmt = function ($v, $field = '') use ($names) { if ($v === null || $v === '') return '—'; $v = (string) $v; if ($field === 'status') return \App\Models\Purchase::STATUSES[$v] ?? $v; if (in_array($field, ['requested_by', 'responsible_id'])) return $names['users'][$v] ?? "#$v"; if ($field === 'supplier_id') return $names['suppliers'][$v] ?? "#$v"; if ($field === 'order_id') return "Order #$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); }; @endphp
← Purchasing

{{ $purchase->product }} × {{ number_format($purchase->quantity) }}

Edit
@csrf @method('DELETE')
@if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ $errors->first() }}
@endif @php $fresh = $history->filter(fn ($l) => $l->user_id !== auth()->id() && (! $lastSeen || $l->created_at->gt($lastSeen))); @endphp @if ($fresh->isNotEmpty())
{{ $fresh->count() }} change(s) by others since you last opened this purchase — see History below.
@endif

Details

@include('purchases._status', ['status' => $purchase->status])
Supplier
{{ $purchase->supplier?->name ?? '—' }}
Client / project
@if ($purchase->order){{ $purchase->order->client }} — {{ $purchase->order->title }} @else {{ $purchase->project ?: '—' }} @endif
Needed by
{{ $purchase->needed_by->format('d.m.Y') }}@if ($purchase->isOverdue()) (overdue)@endif
Requested by
{{ $purchase->requester?->name ?? '—' }}
Responsible
{{ $purchase->responsible?->name ?? '—' }}
Order date
{{ $purchase->ordered_at?->format('d.m.Y') ?? '—' }}
Received date
{{ $purchase->received_at?->format('d.m.Y') ?? '—' }}
@if ($purchase->notes)
{{ $purchase->notes }}
@endif

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

{{-- Comments as a message thread --}}

Comments

@include('purchases._messages', ['comments' => $purchase->comments])
@include('purchases._composer')

History

    @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