@php $cart = session('cart', ['items' => []]); $ids = array_keys($cart['items']); $dishes = count($ids) ? \App\Models\Dish::whereIn('id',$ids)->get()->keyBy('id') : collect(); $count = 0; $subtotal = 0; foreach($cart['items'] as $id => $qty){ $dish = $dishes[$id] ?? null; if(!$dish) continue; $q = is_array($qty) && isset($qty['qty']) ? (int)$qty['qty'] : (int)$qty; $count += $q; $subtotal += ((float)$dish->price) * $q; } $belowMin = false; $atCapacity = false; $minSubtotal = 0; $capacityMsg = null; try { $minSubtotal = (float) \App\Models\Setting::get('order.min_subtotal', 0); $belowMin = $subtotal > 0 && $subtotal < $minSubtotal; $maxOpen = (int) \App\Models\Setting::get('capacity.max_open_orders', 0); if($maxOpen > 0){ $atCapacity = \App\Models\Order::openOrdersCount() >= $maxOpen; } if($atCapacity) { $capacityMsg = 'High kitchen load – prep may be slower'; } } catch (Throwable $e) { /* swallow */ } @endphp @if($count > 0)
@endif