@props(['name', 'value' => null, 'id' => null, 'class' => '', 'required' => false]) @php $calendar = session('calendar', 'jalali'); $inputId = $id ?? $name; $gregorianValue = null; $displayValue = ''; // Normalize the value to a Gregorian Y-m-d string if ($value) { if ($value instanceof \DateTimeInterface) { $gregorianValue = $value->format('Y-m-d'); } elseif (is_string($value) && strlen($value) >= 10) { $gregorianValue = substr($value, 0, 10); } if ($calendar === 'jalali' && $gregorianValue) { try { $displayValue = \Morilog\Jalali\Jalalian::fromDateTime($gregorianValue)->format('Y/m/d'); } catch (\Exception $e) { $displayValue = $gregorianValue; } } else { $displayValue = $gregorianValue ?? ''; } } $defaultClass = 'w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500'; $cssClass = $class ?: $defaultClass; @endphp @if($calendar === 'jalali')
@else @endif