@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 @php $canManageOrders = auth()->user()->hasRestaurantPermission('manage_orders') || auth()->user()->hasRestaurantPermission('update_order_status'); @endphp @section('title', 'Orders Management') @section('styles') @endsection @section('content')
{{ array_sum($statusCounts) }}
Total Orders
{{ $statusCounts['pending'] ?? 0 }}
Pending
{{ $statusCounts['confirmed'] ?? 0 }}
Confirmed
{{ $statusCounts['preparing'] ?? 0 }}
Preparing
@forelse($orders as $order)
#{{ $order->order_number }}
{{ $order->created_at->format('d M Y, h:i A') }}
{{ $order->customer_name ?? 'Guest' }}
{{ $order->customer_phone ?? 'N/A' }}
{{ $currencySymbol }}{{ number_format($order->total, App\Models\AppSetting::currencyDecimals()) }}
{{ ucfirst(str_replace('_', ' ', $order->status)) }}
Order Items
@php $itemsList = []; // Prefer orderItems relation so menu item images are available. if ($order->orderItems && $order->orderItems->count() > 0) { $itemsList = $order->orderItems->toArray(); } elseif ($order->items) { if (is_string($order->items)) { $itemsList = json_decode($order->items, true); } elseif (is_array($order->items)) { $itemsList = $order->items; } } // Ensure it's an array if (!is_array($itemsList)) { $itemsList = []; } @endphp @if(count($itemsList) > 0) @foreach(array_slice($itemsList, 0, 3) as $item) @php // Get item details safely $itemName = 'Item'; $itemQty = 1; $itemPrice = 0; $itemImage = null; if (is_array($item)) { $itemName = $item['name'] ?? $item['item_name'] ?? data_get($item, 'menu_item.name') ?? $item['title'] ?? 'Item'; $itemQty = $item['quantity'] ?? $item['qty'] ?? 1; $itemPrice = $item['price'] ?? $item['unit_price'] ?? 0; $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 ); } @endphp
@if($itemImage) {{ $itemName }} @else
@endif
{{ $itemName }}
x{{ $itemQty }}
{{ $currencySymbol }}{{ number_format($itemPrice * $itemQty, App\Models\AppSetting::currencyDecimals()) }}
@endforeach @if(count($itemsList) > 3) +{{ count($itemsList) - 3 }} more items @endif @else
No items found
@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((float) $order->discount > 0)
Coupon Discount: -{{ $currencySymbol }}{{ number_format($order->discount, App\Models\AppSetting::currencyDecimals()) }}
@endif
Total Bill Payable: {{ $currencySymbol }}{{ number_format($order->total, App\Models\AppSetting::currencyDecimals()) }}
@if(($order->payout_status ?? '') === 'Payout Released')
Payout Released
@endif
{{ strtoupper($order->payment_method) }} {{ ucfirst($order->payment_status) }}

View Details @if($canManageOrders && $order->status == 'pending') @elseif($canManageOrders && $order->status == 'confirmed') @elseif($canManageOrders && $order->status == 'preparing') @endif
@empty

No Orders Found

When customers place orders, they will appear here

@endforelse
{{ $orders->withQueryString()->links() }}
@endsection @section('scripts') @endsection