@props([ 'restaurant' => null, 'value' => null, 'compact' => false, ]) @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'; $pickerTz = $restaurantObj?->timezone ?? config('app.timezone'); $currentTime = $value ?? now($pickerTz)->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($pickerTz)->format('H:i'); } $timeObj = now($pickerTz)->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'))); $defaultInputClass = $compact ? 'inline-flex items-center w-full h-8 max-h-8 min-h-0 box-border pl-2.5 pr-8 py-0 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-500 rounded-lg text-xs leading-tight text-gray-700 dark:text-gray-300 shadow-sm focus:outline-none focus:ring-2 focus:ring-gray-500 cursor-pointer relative z-10' : 'inline-flex items-center w-full min-h-[2.5rem] box-border pl-3 pr-10 py-1.5 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-500 rounded-lg text-sm leading-tight text-gray-700 dark:text-gray-300 shadow-sm focus:outline-none focus:ring-2 focus:ring-gray-500 cursor-pointer relative z-10'; @endphp
merge(['class' => $defaultInputClass]) !!}>