@extends('layouts.dashboard') @section('content') @php /** * Vendor → Menu → Add / Edit item. The routed page form (own URL, full dashboard * chrome) that replaced the #itemModal Bootstrap modal. The field ids, names and * the populate/ingredient-builder JS are the modal's own — moved here verbatim — * so MenuController::saveItem() receives an identical POST and needs no change. * The layout is rebuilt to page standards: dashboard cards, qm-switch-row toggles * (right-aligned, one per row) and the canonical qm-tabs ingredient picker. * On edit, a hidden #item-form-seed carries the row's data-* attributes (exactly * the old edit button's) and the populate function runs once on load. * * @var array|null $item the menu item being edited, or null when adding * @var object|array $itemIngMap this item's ingredient map { id: {d,r,p} } (edit) * @var array $categories restaurant menu categories * @var array $ingredients grouped active ingredient library * @var array $schedules restaurant availability schedules * @var array $stations kitchen stations (empty when the kitchen is undivided) * @var array $allowance plan menu-item allowance */ use App\Services\MenuSchedule; $isEdit = $item !== null; $item = $item ?? null; $stations = $stations ?? []; $itemIngMap = $itemIngMap ?? new stdClass(); // The admin owns this list. It was hardcoded here AND again in Helpers, so adding one meant // editing two files and the two could disagree; the EU mandates 14 and this shipped 9. $allergenOptions = \App\Models\Dimension::options(\App\Models\Dimension::ALLERGENS); // Attribute toggles: [field id, POST name, label key, default-checked-on-add]. $attrToggles = [ ['item-veg', 'is_veg', 'vendor.menu.attr_vegetarian', false], ['item-available', 'is_available', 'vendor.menu.available_label', true], ['item-popular', 'is_popular', 'vendor.menu.popular_pill', false], ]; /* Those three keep their own columns because they are not descriptions of the dish: is_veg a real diet filter, drawn as the veg/non-veg dot and used across the storefront is_available the dish's state is_popular a merchandising flag The six that used to sit under them — eggs, chef's pick, zesty, sweet, fruity, baked — were six more boolean COLUMNS, so a buyer wanting "Halal" needed an ALTER TABLE. They are rows now. */ $attrRows = \App\Models\Dimension::attributeIcons(); $itemAttrs = array_filter(array_map('trim', explode(',', (string) ($item['attributes'] ?? '')))); $ingCatKeys = [ 'proteins' => 'common.ingredient_cat_proteins', 'dairy' => 'common.ingredient_cat_dairy', 'breads' => 'common.ingredient_cat_breads', 'vegetables' => 'common.ingredient_cat_vegetables', 'fruits' => 'common.ingredient_cat_fruits', 'sauces' => 'common.ingredient_cat_sauces', 'grains' => 'common.ingredient_cat_grains', 'herbs' => 'common.ingredient_cat_herbs', ]; @endphp @php /* .qm-d2: the dashboard density standard (app.css §35) */ @endphp