@extends('layouts.restaurant') @php $currencySymbol = App\Models\AppSetting::getValue('currency_symbol', '?'); $itemImageUrl = function ($image) { if (is_array($image)) { $image = collect($image)->filter()->first(); } if (!$image) { return null; } return str_starts_with((string) $image, 'http://') || str_starts_with((string) $image, 'https://') ? $image : \Illuminate\Support\Facades\Storage::disk('public')->url($image); }; @endphp @section('title', 'Order #' . $order->order_number) @section('styles') @endsection @section('content')
Order Status Timeline
@php $statusFlow = ['pending', 'confirmed', 'preparing', 'ready_for_pickup', 'picked_up', 'on_the_way', 'delivered']; $currentIndex = array_search($order->status, $statusFlow); $statusLabels = [ 'pending' => 'Order Placed', 'confirmed' => 'Confirmed', 'preparing' => 'Preparing', 'ready_for_pickup' => 'Ready for Pickup', 'picked_up' => 'Picked Up', 'on_the_way' => 'On The Way', 'delivered' => 'Delivered' ]; @endphp @foreach($statusFlow as $index => $status) @php $isCompleted = $index <= $currentIndex; $isActive = $index == $currentIndex; @endphp
@if($status == 'pending') @elseif($status == 'confirmed') @elseif($status == 'preparing') @elseif($status == 'ready_for_pickup') @elseif($status == 'reached_pickup') @elseif($status == 'picked_up') @elseif($status == 'on_the_way') @elseif($status == 'delivered') @endif
{{ $statusLabels[$status] }}
@endforeach
Order Items
@php $orderItems = []; // Prefer orderItems relation so menu item images are available. if ($order->orderItems && $order->orderItems->count() > 0) { $orderItems = $order->orderItems->toArray(); } elseif ($order->items) { if (is_string($order->items)) { $orderItems = json_decode($order->items, true); } elseif (is_array($order->items)) { $orderItems = $order->items; } } if (!is_array($orderItems)) { $orderItems = []; } @endphp @if(count($orderItems) > 0) @foreach($orderItems as $item) @php // Safe extraction of item details $itemName = 'Item'; $itemQty = 1; $itemPrice = 0; $itemTotal = 0; $itemImage = null; if (is_array($item)) { $itemName = $item['name'] ?? $item['item_name'] ?? data_get($item, 'menu_item.name') ?? $item['title'] ?? 'Item'; $itemQty = (int) ($item['quantity'] ?? $item['qty'] ?? 1); $itemPrice = (float) ($item['unit_price'] ?? $item['price'] ?? 0); $itemTotal = (float) ($item['total_price'] ?? $item['total'] ?? ($itemPrice * $itemQty)); $itemImage = $itemImageUrl( $item['image'] ?? $item['image_url'] ?? $item['thumbnail'] ?? $item['photo'] ?? $item['images'] ?? data_get($item, 'menu_item.image') ?? data_get($item, 'menu_item.images') ?? null ); if ($itemPrice <= 0 && $itemQty > 0 && $itemTotal > 0) { $itemPrice = $itemTotal / $itemQty; } } @endphp
@if($itemImage) {{ $itemName }} @else
@endif
{{ $itemName }}
Qty: {{ $itemQty }} x {{ $currencySymbol }}{{ number_format($itemPrice, App\Models\AppSetting::currencyDecimals()) }}
{{ $currencySymbol }}{{ number_format($itemTotal ?? ($itemPrice * $itemQty), App\Models\AppSetting::currencyDecimals()) }}
@endforeach @else
No items found for this order
@endif
Subtotal {{ $currencySymbol }}{{ number_format($order->subtotal, App\Models\AppSetting::currencyDecimals()) }}
Delivery Fee {{ $currencySymbol }}{{ number_format($order->delivery_fee, App\Models\AppSetting::currencyDecimals()) }}
Platform Fee {{ $currencySymbol }}{{ number_format($order->platform_fee ?? 0, App\Models\AppSetting::currencyDecimals()) }}
Taxes & Charges {{ $currencySymbol }}{{ number_format($order->tax, App\Models\AppSetting::currencyDecimals()) }}
@if($order->discount > 0)
Discount -{{ $currencySymbol }}{{ number_format($order->discount, App\Models\AppSetting::currencyDecimals()) }}
@endif
Total Bill Payable {{ $currencySymbol }}{{ number_format($order->total, App\Models\AppSetting::currencyDecimals()) }}
Customer Information
Name {{ $order->customer_name ?? 'Guest' }}
Phone {{ $order->customer_phone ?? 'N/A' }}
@if($order->customer)
Email {{ $order->customer->email ?? 'N/A' }}
@endif
Delivery Address {{ $order->delivery_address ?? 'Address not provided' }}
@if($order->scheduled_time)
Scheduled For {{ $order->scheduled_time->format('d M Y, h:i A') }}
@endif @if($order->special_instructions)
Special instructions
{{ $order->special_instructions }}
@endif
Payment Information
Payment Method {{ strtoupper($order->payment_method) }}
Payment Status {{ ucfirst($order->payment_status) }}
@if($order->payment_id)
Transaction ID {{ $order->payment_id }}
@endif
Delivery Information
Order Date {{ $order->created_at->format('d M Y, h:i A') }}
@if($order->delivered_at)
Delivered At {{ $order->delivered_at->format('d M Y, h:i A') }}
@endif @if($order->cancelled_at)
Cancelled At {{ $order->cancelled_at->format('d M Y, h:i A') }}
Cancellation Reason {{ $order->cancellation_reason ?? 'No reason provided' }}
@endif @if($order->driver)
Delivery Partner {{ $order->driver->name ?? 'Not assigned' }}
@endif
Actions
@if($order->status == 'pending') @elseif($order->status == 'confirmed') @elseif($order->status == 'preparing') @endif
@endsection