85 lines
2.9 KiB
PHP
85 lines
2.9 KiB
PHP
<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;
|
|
|
|
$__newAttributes = [];
|
|
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames((['name', 'value' => null, 'id' => null, 'class' => '', 'required' => false]));
|
|
|
|
foreach ($attributes->all() as $__key => $__value) {
|
|
if (in_array($__key, $__propNames)) {
|
|
$$__key = $$__key ?? $__value;
|
|
} else {
|
|
$__newAttributes[$__key] = $__value;
|
|
}
|
|
}
|
|
|
|
$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);
|
|
|
|
unset($__propNames);
|
|
unset($__newAttributes);
|
|
|
|
foreach (array_filter((['name', 'value' => null, 'id' => null, 'class' => '', 'required' => false]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
|
|
$$__key = $$__key ?? $__value;
|
|
}
|
|
|
|
$__defined_vars = get_defined_vars();
|
|
|
|
foreach ($attributes->all() as $__key => $__value) {
|
|
if (array_key_exists($__key, $__defined_vars)) unset($$__key);
|
|
}
|
|
|
|
unset($__defined_vars); ?>
|
|
|
|
<?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;
|
|
?>
|
|
|
|
<?php if($calendar === 'jalali'): ?>
|
|
<div class="jalali-date-wrapper relative" data-picker="jalali">
|
|
<input type="text"
|
|
id="<?php echo e($inputId); ?>_display"
|
|
class="jalali-datepicker-input <?php echo e($cssClass); ?>"
|
|
value="<?php echo e($displayValue); ?>"
|
|
placeholder="1404/03/15"
|
|
autocomplete="off"
|
|
data-gregorian-target="<?php echo e($inputId); ?>"
|
|
<?php echo e($required ? 'required' : ''); ?>
|
|
|
|
dir="ltr" />
|
|
<input type="hidden"
|
|
id="<?php echo e($inputId); ?>"
|
|
name="<?php echo e($name); ?>"
|
|
value="<?php echo e($gregorianValue); ?>" />
|
|
</div>
|
|
<?php else: ?>
|
|
<input type="date"
|
|
id="<?php echo e($inputId); ?>"
|
|
name="<?php echo e($name); ?>"
|
|
value="<?php echo e($gregorianValue); ?>"
|
|
class="<?php echo e($cssClass); ?>"
|
|
<?php echo e($required ? 'required' : ''); ?> />
|
|
<?php endif; ?>
|
|
<?php /**PATH C:\xampp\htdocs\projectra\resources\views/components/date-input.blade.php ENDPATH**/ ?>
|