@extends('layouts.public') @section('content') @php use App\Models\Order; /** @var array $orders */ /** @var string $filter */ /** @var array $counts */ /** @var array $pager */ $filter = $filter ?? ''; $counts = $counts ?? ['all' => count($orders), 'active' => 0, 'past' => 0]; /** @var array $reviewedOrders order id => review id for the customer's orders that already have their own review */ $reviewedOrders = $reviewedOrders ?? []; $tabs = [ '' => ['label' => t_raw('common.all'), 'href' => route('account.orders'), 'count' => $counts['all'] ?? 0], 'active' => ['label' => t_raw('account.tab_active'), 'href' => route('account.orders') . '?f=active', 'count' => $counts['active'] ?? 0], 'past' => ['label' => t_raw('account.tab_past'), 'href' => route('account.orders') . '?f=past', 'count' => $counts['past'] ?? 0], ]; @endphp

{{ t_raw('header.my_orders') }}

@php /* The page's messages belong UNDER its title band, inside the page the reader is looking at — not floating above it. getFlashes() consumes, so the layout's own call further out finds nothing and does not draw it twice. */ @endphp
@partial('flash')
@partial('account-nav')

{{ t_raw('footer.order_history') }}

@if (count($orders))
@foreach ($orders as $o) @php /* HOW IT WAS PAID, beside what it cost. The list said an order came to $19.44 and nothing about whether that money had left — a customer could not tell a card payment from one still owed to the driver. Same mark the rest of the product uses for a tender, and the unpaid case says so rather than staying silent. */ @endphp @endforeach
{{ t_raw('common.order') }}{{ t_raw('common.restaurant') }}{{ t_raw('common.total') }}{{ t_raw('account.col_paid_with') }}{{ t_raw('common.status') }}{{ t_raw('common.date') }}{{ t_raw('account.col_manage') }}
{{ $o['order_number'] }} @if (!empty($o['first_item_name'])){{ $o['first_item_name'] }}@endif
{!! restaurant_logo_html(['logo' => $o['restaurant_logo'] ?? '', 'name' => $o['restaurant_name']], 'sm') !!}
{{ $o['restaurant_name'] }}
{{ money($o['total']) }} @php $pm = (string) ($o['payment_method'] ?? ''); @endphp @php $ico = $pm !== '' ? payment_method_icon($pm) : ''; @endphp {!! $ico !== '' ? $ico : ($pm !== '' ? status_label('payment_method', $pm) : dash()) !!} @if ((string) ($o['payment_status'] ?? '') === 'unpaid') {{ t_raw('status.payment.unpaid') }} @endif {{ Order::statusLabel($o['status'], $o['service_mode'] ?? 'delivery') }} {!! fmt_datetime($o['placed_at']) !!}
@php $isPast = in_array($o['status'], ['delivered', 'cancelled'], true); // Live tracking is only meaningful while an order is in progress; a // completed or cancelled order is history and cannot be tracked. @endphp @if (!$isPast && !empty($o['track_token'])) {{ t_raw('home.reorder.track') }} @endif @if ($o['status'] === 'delivered') {{-- Per-order: only this order having its own review shows "Your review". --}} @if (isset($reviewedOrders[(int) $o['id']])) {{ t_raw('account.your_review_btn') }} @else {{ t_raw('account.leave_review_btn') }} @endif @endif
@csrf
@partial('table-toolbar', ['pager' => $pager, 'base' => '/account/orders']) @else
@if ($filter === 'active')

{{ t_raw('account.no_active_orders') }}

@elseif ($filter === 'past')

{{ t_raw('account.no_past_orders') }}

@else

{{ t_raw('account.no_orders_placed_yet') }}

@endif {{ t_raw('restaurant.browse') }}
@endif
@endsection