@props([ 'name', // اسم الحقل (مطلوب) 'id' => null, // معرف الحقل (اختياري - يستخدم الاسم افتراضياً) 'value' => null, // القيمة الحالية 'label' => null, // عنوان الحقل 'type' => 'file', // نوع الملف: image, audio, file 'required' => false, // هل الحقل مطلوب 'disabled' => false, // هل الحقل معطل 'buttonText' => null, // نص الزر (اختياري) 'buttonIcon' => null, // أيقونة الزر (اختياري) 'showClear' => true, // إظهار زر الحذف 'showPreview' => true, // إظهار المعاينة 'size' => 'normal', // حجم الحقل: normal, sm 'placeholder' => '', // النص الافتراضي 'helpText' => null, // نص مساعد 'previewHeight' => '100px', // ارتفاع المعاينة للصور 'class' => '', // كلاسات إضافية للحاوية 'inputClass' => '', // كلاسات إضافية للحقل ]) @php $inputId = $id ?? $name; $previewId = $inputId . '_preview'; // First try to get old value (for form re-submission after validation error) // Then fallback to the passed value $oldValue = old($name); $currentValue = $oldValue !== null ? $oldValue : $value; // Trim any whitespace from the value $currentValue = $currentValue ? trim($currentValue) : null; $hasError = $errors->has($name); // تحديد الأيقونة والنص الافتراضي بناءً على النوع $defaultIcons = [ 'image' => 'fa-image', 'audio' => 'fa-volume-up', 'file' => 'fa-folder-open', 'video' => 'fa-video', 'pdf' => 'fa-file-pdf', ]; $defaultTexts = [ 'image' => __('trans.lfm.choose_image'), 'audio' => __('trans.lfm.choose_audio'), 'file' => __('trans.lfm.choose_file'), 'video' => __('trans.lfm.choose_video'), 'pdf' => __('trans.lfm.choose_pdf'), ]; $icon = $buttonIcon ?? ($defaultIcons[$type] ?? 'fa-folder-open'); $text = $buttonText ?? ($defaultTexts[$type] ?? __('trans.lfm.choose_file')); $sizeClass = $size === 'sm' ? 'input-group-sm' : ''; $btnSizeClass = $size === 'sm' ? 'btn-sm' : ''; @endphp
@if($label) @endif
@if($showClear) @endif
@if($showPreview)
@if($currentValue) @if($type === 'image') Preview @elseif($type === 'audio') @else @endif @endif
@endif @if($helpText)
{{ $helpText }}
@endif @error($name)
{{ $message }}
@enderror
@once @push('css') @endpush @push('js') @endpush @endonce