@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')
{{ $helpText }}
@endif @if($showExisting) @if($existingRows->isEmpty())لا توجد مرفقات مسجّلة بعد.
@else|
@if($isImage)
|
{{ $att->file_name }} | {{ $att->file_type ?? '—' }} | {{ $att->file_size ? number_format((int) $att->file_size / 1024, 1).' ك.ب' : '—' }} | فتح | @if($allowDelete)@endif |
{{ $helpText }}
@endif @if($showExisting) @if($existingRows->isEmpty())لا توجد مرفقات مسجّلة بعد.
@else|
|
|
|
|
|
@if($allowDelete)
|
@endif
|---|---|---|---|---|---|
|
@if($isImage)
|
{{ $att->file_name }} | {{ $att->file_type ?? '—' }} | {{ $att->file_size ? number_format((int) $att->file_size / 1024, 1).' ك.ب' : '—' }} | فتح | @if($allowDelete)@endif |
{{ $message }}
@enderror @error('attachments.*'){{ $message }}
@enderror