@php // Get restaurant from prop, helper, or request hash (similar to datepicker) $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 time format from restaurant or use default $timeFormat = $restaurantObj?->time_format ?? 'h:i A'; $currentTime = $value ?? now()->format('H:i'); // Normalize time format if ($currentTime && preg_match('/(\d{1,2}):(\d{1,2})/', $currentTime, $matches)) { $currentTime = str_pad((int)$matches[1], 2, '0', STR_PAD_LEFT) . ':' . str_pad((int)$matches[2], 2, '0', STR_PAD_LEFT); } else { $currentTime = now()->format('H:i'); } $timeObj = now()->setTimeFromTimeString($currentTime); $hour24 = (int)$timeObj->format('H'); $minute = (int)$timeObj->format('i'); $is24Hour = $timeFormat === 'H:i'; $hour12 = $is24Hour ? $hour24 : ($hour24 % 12 ?: 12); // Detect if format uses uppercase 'A' or lowercase 'a' for AM/PM $isUpperCaseAmPm = strpos($timeFormat, 'A') !== false; $ampmValue = $is24Hour ? '' : ($isUpperCaseAmPm ? strtoupper($timeObj->format('A')) : strtolower($timeObj->format('A'))); @endphp