@props([ 'existing' => [], 'hintField' => null, 'title' => 'المرفقات', 'inputName' => 'attachments[]', 'accept' => '.jpg,.jpeg,.png,.gif,.webp,.pdf,.doc,.docx,.xls,.xlsx,.txt,.csv', 'theme' => 'tailwind', 'helpText' => null, 'showExisting' => true, 'uploadable' => true, 'allowDelete' => true, ]) @php $existingRows = $existing instanceof \Illuminate\Support\Collection ? $existing : collect($existing); $erpAttachmentIsRenderableImage = static function ($att): bool { $mime = strtolower(trim((string) ($att->file_type ?? ''))); $ext = strtolower((string) pathinfo((string) ($att->file_name ?? ''), PATHINFO_EXTENSION)); $imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg', 'avif', 'heic', 'heif']; if ($mime !== '' && str_starts_with($mime, 'image/')) { return true; } if ($ext !== '' && in_array($ext, $imageExtensions, true)) { return true; } if ($mime === 'application/octet-stream' && $ext !== '' && in_array($ext, $imageExtensions, true)) { return true; } return false; }; @endphp @if($theme === 'bootstrap')
@if($hintField) @endif {{ $title }}
@if($helpText)

{{ $helpText }}

@endif @if($showExisting) @if($existingRows->isEmpty())

لا توجد مرفقات مسجّلة بعد.

@else
@if($allowDelete) @endif @foreach($existingRows as $att) @php $url = asset('storage/'.ltrim($att->file_path ?? '', '/')); $isImage = $erpAttachmentIsRenderableImage($att); @endphp @if($allowDelete) @endif @endforeach
معاينة اسم الملف النوع الحجم رابط حذف
@if($isImage) @else @endif {{ $att->file_name }} {{ $att->file_type ?? '—' }} {{ $att->file_size ? number_format((int) $att->file_size / 1024, 1).' ك.ب' : '—' }} فتح
@endif @endif @if($uploadable)
@error('attachments')
{{ $message }}
@enderror @error('attachments.*')
{{ $message }}
@enderror
@endif
@else

{{ $title }}

@if($hintField) @endif
@if($helpText)

{{ $helpText }}

@endif @if($showExisting) @if($existingRows->isEmpty())

لا توجد مرفقات مسجّلة بعد.

@else
@if($allowDelete) @endif @foreach($existingRows as $att) @php $url = asset('storage/'.ltrim($att->file_path ?? '', '/')); $isImage = $erpAttachmentIsRenderableImage($att); @endphp @if($allowDelete) @endif @endforeach
معاينة اسم الملف النوع الحجم رابط حذف
@if($isImage) @else @endif {{ $att->file_name }} {{ $att->file_type ?? '—' }} {{ $att->file_size ? number_format((int) $att->file_size / 1024, 1).' ك.ب' : '—' }} فتح
@endif @endif @if($uploadable)
@error('attachments')

{{ $message }}

@enderror @error('attachments.*')

{{ $message }}

@enderror
@endif
@endif