@extends('layouts.dashboard') @section('content') @php /** * Shared add/edit reservation form. * @var bool $editing @var array|null $res @var array $tables @var array $labels * @var string $date @var array $closedDows @var array $blackoutDates * @var int $maxParty @var int $defaultDuration @var int $leadMinutes */ $editing = $editing ?? false; $res = $res ?? null; $tables = $tables ?? []; $labels = $labels ?? []; $maxParty = (int) ($maxParty ?? 50); $defaultDuration = (int) ($defaultDuration ?? 90); $leadMinutes = (int) ($leadMinutes ?? 0); $val = static function (string $key, $fallback = '') use ($res, $__env) { return $res[$key] ?? $fallback; }; // Per-field validation errors stashed by the controller on a failed submit (keyed by // field name). Read raw so we can index it; absent on a clean load. Drives the // aria-invalid / aria-describedby wiring below for accessible, inline error reporting. $fieldErrors = \App\Support\Session::old('__errors', []); $fieldErrors = is_array($fieldErrors) ? $fieldErrors : []; $err = static function (string $field) use ($fieldErrors, $__env): string { return isset($fieldErrors[$field][0]) ? (string) $fieldErrors[$field][0] : ''; }; $resTime = $editing && !empty($res['reserved_at']) ? date('H:i', strtotime((string) $res['reserved_at'])) : '19:00'; $resDur = $editing ? (int) ($res['duration_minutes'] ?? $defaultDuration) : $defaultDuration; $resTable = (int) ($res['table_id'] ?? 0) ?: (int) ($prefillTable ?? 0); $resLabel = (int) ($res['label_id'] ?? 0); $resLabelColor = '#64748b'; foreach ($labels as $lbl) { if ((int) ($lbl['id'] ?? 0) === $resLabel) { $resLabelColor = (string) $lbl['color']; } } $durations = [30, 45, 60, 90, 120, 150, 180, 240]; $closedJson = implode(',', array_map('intval', $closedDows ?? [])); $blackoutJson = implode(',', array_map('strval', $blackoutDates ?? [])); $action = $editing ? '/vendor/reservations/update' : '/vendor/reservations/save'; @endphp @php /* .qm-d2: the dashboard density standard (app.css ยง35) */ @endphp
{!! $editing ? t('vendor.reservations.form_sub_edit') : t('vendor.reservations.form_sub_new') !!}