@php // Get restaurant from prop, helper, or request hash (similar to Cart.php) $restaurantObj = $restaurant ?? null; // If restaurant prop not provided, try restaurant() helper if (!$restaurantObj) { $restaurantObj = restaurant(); } // If still not available, try to get from request hash (for customer pages) if (!$restaurantObj) { $hash = request()->route('hash') ?? request()->query('hash'); if ($hash) { // Try shop() helper first $restaurantObj = shop($hash); // If shop() doesn't work, query directly if (!$restaurantObj) { $restaurantObj = \App\Models\Restaurant::where('hash', $hash)->first(); } } } // Get date format from restaurant or use default $phpFormat = $restaurantObj?->date_format ?? 'd-m-Y'; // cSpell:ignore pikaday $pikadayFormat = str_replace(['d', 'm', 'Y', 'y'], ['DD', 'MM', 'YYYY', 'YY'], $phpFormat); $currentDate = now()->format($phpFormat); $currentDateJs = now()->format('Y-m-d'); // Get value from attributes if provided $value = $attributes->get('value'); // Get minDate and maxDate from attributes if provided $minDate = $attributes->get('minDate'); $maxDate = $attributes->get('maxDate'); // Parse dates to JavaScript format if provided $minDateJs = 'null'; $maxDateJs = 'null'; if ($minDate) { try { $carbonDate = \Carbon\Carbon::createFromFormat($phpFormat, $minDate); $minDateJs = "new Date(" . $carbonDate->year . ", " . ($carbonDate->month - 1) . ", " . $carbonDate->day . ")"; } catch (\Exception $e) { // If parsing fails, try to parse as is $minDateJs = "new Date('" . $minDate . "')"; } } if ($maxDate) { try { $carbonDate = \Carbon\Carbon::createFromFormat($phpFormat, $maxDate); $maxDateJs = "new Date(" . $carbonDate->year . ", " . ($carbonDate->month - 1) . ", " . $carbonDate->day . ")"; } catch (\Exception $e) { // If parsing fails, try to parse as is $maxDateJs = "new Date('" . $maxDate . "')"; } } // Remove minDate, maxDate, and value from attributes so they don't appear as HTML attributes $attributes = $attributes->except(['minDate', 'maxDate', 'value']); // Set initial value - use provided value, or current date in restaurant format if no value $initialValue = $value ?: $currentDate; @endphp merge(['class' => 'inline-flex items-center px-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-500 rounded-lg text-lg text-gray-700 dark:text-gray-300 shadow-sm hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 disabled:opacity-25 transition ease-in-out duration-150 w-full']) !!}>