{{-- resources/views/admin/orders/show.blade.php --}} @extends('admin.layouts.app') @section('title', 'Encomenda #' . $order->id) @php // Ajusta labels aos estados reais do teu orders.status $labels = [ 'processing' => 'Em processamento', 'completed' => 'Concluída', 'cancelled' => 'Cancelada', 'refunded' => 'Reembolsada', ]; $currentStatus = $order->status ?? 'pending'; @endphp @section('content')
{{-- Header --}}

Encomenda #{{ $order->id }}

Clube: {{ optional($order->club)->name ?? '—' }} / Cliente: {{ optional($order->user)->name ?? ('User #' . $order->user_id) }} / Estado: {{ $labels[$currentStatus] ?? $currentStatus }}
{{-- Flash --}} @if (session('status'))
{{ session('status') }}
@endif @if (session('error'))
{{ session('error') }}
@endif @if ($errors->any())
Há erros no formulário.
@endif {{-- Resumo --}}
Resumo
Criada em
{{ $order->created_at ? \Carbon\Carbon::parse($order->created_at)->format('d/m/Y H:i') : '—' }}
@if(!empty($order->paid_at)) Paga em: {{ \Carbon\Carbon::parse($order->paid_at)->format('d/m/Y H:i') }} @endif
Totais
Subtotal € {{ number_format((float)($order->subtotal ?? 0), 2, ',', '.') }}
Descontos € {{ number_format((float)($order->discount_total ?? 0), 2, ',', '.') }}
Portes € {{ number_format((float)($order->shipping_total ?? 0), 2, ',', '.') }}
IVA € {{ number_format((float)($order->tax_total ?? 0), 2, ',', '.') }}
Total € {{ number_format((float)($order->grand_total ?? $order->total ?? 0), 2, ',', '.') }}
Valores conforme gravados na encomenda.
Estado
@csrf
@error('status')
{{ $message }}
@enderror
Alterar o estado ajuda a organizar listagens e fluxo operacional.
@if(!empty($order->notes))
Notas
{{ $order->notes }}
@endif
{{-- Itens --}}
Itens
@forelse($order->lines ?? [] as $ln) @php $p = $ln->product ?? null; $mainImagePath = $p ? ($p->image_url ?? optional($p->images->first())->path) : null; $mainImageUrl = $mainImagePath ? asset('storage/' . ltrim($mainImagePath, '/')) : null; @endphp @empty @endforelse
Produto Preço Qtd Total
@if($mainImageUrl) {{ $ln->product_name ?? 'Produto' }} @else
Sem imagem
@endif
{{ $ln->product_name ?? '—' }}
ID produto: {{ $ln->product_id }}
€ {{ number_format((float)($ln->unit_price ?? 0), 2, ',', '.') }} {{ (int)($ln->quantity ?? 0) }} € {{ number_format((float)($ln->line_total ?? 0), 2, ',', '.') }}
Sem itens nesta encomenda.
@endsection