@extends('layouts.public') @section('content') @php // Which landing page this is: its bands read this page's own switches. \App\Services\HomeSection::rendering('order_builder'); /** @var array $restaurants each restaurant row with an 'items' array * @var array $optJson item id => option-groups JSON string (from PreviewMenu) * @var array $ingJson item id => ingredients JSON string (from PreviewMenu) */ $optJson = $optJson ?? []; $ingJson = $ingJson ?? []; $foodTypeMap = $foodTypeMap ?? []; // Category names come from the controller. This template used to query for them itself. $catNames = $catNames ?? []; // Build a compact, safe payload for the client-side builder. $payload = []; foreach ($restaurants as $r) { $items = []; foreach ($r['items'] as $it) { $catId = (int) ($it['menu_category_id'] ?? 0); $iid = (int) $it['id']; $items[] = [ 'id' => $iid, 'name' => (string) $it['name'], 'desc' => (string) ($it['description'] ?? ''), 'price' => (float) $it['price'], 'veg' => (int) ($it['is_veg'] ?? 0) === 1, 'pop' => (int) ($it['is_popular'] ?? 0) === 1, 'image' => media($it['image'], 'assets/client/dish/dish-1.png'), 'catId' => $catId, 'cat' => $catId && isset($catNames[$catId]) ? $catNames[$catId] : t_raw('order_builder.more_category'), // Customization data so a card can open the shared customize popup. 'czOptions' => json_decode(($optJson[$iid] ?? '[]'), true) ?: [], 'czIngs' => json_decode(($ingJson[$iid] ?? '[]'), true) ?: [], ]; } $payload[] = [ 'id' => (int) $r['id'], 'name' => (string) $r['name'], 'cuisine' => (string) ($r['cuisine_name'] ?? ''), 'city' => (string) ($r['city'] ?? ''), 'prep' => (int) ($r['avg_prep_time'] ?? 0), 'rating' => number_format((float) ($r['rating_cache'] ?? 0), 1), 'minOrder' => (float) ($r['min_order'] ?? 0), 'cover' => media($r['cover_image'] ?? null, 'assets/client/covers/shop-1.png'), 'foodTypes' => array_values($foodTypeMap[(int) $r['id']] ?? []), 'items' => $items, ]; } $currency = setting('currency_symbol', '$'); $obI18n = [ 'moreCategory' => t_raw('order_builder.more_category'), 'allCategory' => t_raw('common.all'), 'boardSubDefault' => t_raw('order_builder.board_sub_default'), 'noDishesMatch' => t_raw('order_builder.no_dishes_match'), 'vegetarian' => t_raw('restaurant.diet_veg'), 'nonVegetarian' => t_raw('common.non_vegetarian'), 'popular' => t_raw('vendor.menu.popular_pill'), 'ariaCustomiseAdd' => t_raw('order_builder.aria_customise_add'), 'noKitchensFoodtype' => t_raw('order_builder.no_kitchens_foodtype'), 'lineUpdated' => t_raw('order_builder.line_updated'), 'lineAdded' => t_raw('order_builder.line_added'), 'dishNotOnMenu' => t_raw('order_builder.dish_not_on_menu'), 'ariaEditLine' => t_raw('order_builder.aria_edit_line'), 'ariaDecreaseQty' => t_raw('common.decrease_quantity'), 'ariaIncreaseQty' => t_raw('common.increase_quantity'), 'ariaRemoveLine' => t_raw('order_builder.aria_remove_line'), 'countOne' => t_raw('order_builder.count_one'), 'countMany' => t_raw('order_builder.count_many'), 'minReached' => t_raw('order_builder.min_reached'), 'minRemaining' => t_raw('order_builder.min_remaining'), 'clearConfirmBody' => t_raw('order_builder.clear_confirm_body'), 'clearConfirmTitle' => t_raw('order_builder.clear_confirm_title'), 'clearConfirmYes' => t_raw('admin.advanced.clear_confirm_yes'), 'toastCleared' => t_raw('order_builder.toast_cleared'), 'addingLabel' => t_raw('order_builder.adding_label'), 'errAddGeneric' => t_raw('order_builder.err_add_generic'), 'errAddToast' => t_raw('order_builder.err_add_toast'), 'eachSuffix' => t_raw('order_builder.each_suffix'), ]; @endphp @php /* The hero (the drag-&-drop teaser) and the "Browse by food type" strip, drawn in whatever order the operator arranged in Admin → Pages. The builder itself follows below and is not a band: it is the page, not a strip on it. */ echo \App\Services\HomeSection::draw('order_builder', get_defined_vars(), [ // The hero teases the builder with dishes cut from this page's own payload, so it is built here. 'hero-order-builder' => static fn (): string => partial('sections/hero-order-builder', ['hxDishes' => array_slice($payload[0]['items'] ?? [], 0, 4)]), ]); @endphp
@if (!$restaurants)

{{ t_raw('order_builder.empty_state') }}

@else
1

{{ t_raw('order_builder.step1_title') }}

{{ t_raw('order_builder.step1_sub') }}

@foreach ($payload as $idx => $r) @endforeach
2

{{ t_raw('order_builder.step2_title') }}

{{ t_raw('order_builder.board_sub_default') }}

{{ t_raw('restaurant.menu') }}
3

{{ t_raw('order_builder.step3_title') }}

{{ t_raw('order_builder.step3_sub') }}

{{ t_raw('order_builder.basket_empty_title') }}
{{ t_raw('order_builder.basket_empty_sub') }}

{{ t_raw('common.total') }} {{ t_raw('order_builder.count_many', [':n' => 0]) }} {{ $currency }}0.00
@partial('order-customize-modal', ['cur' => $currency]) @endif
@endsection