@php $getFileUrl = function($filePath) { $normalizedPath = trim((string) $filePath); $normalizedPath = str_replace('\\', '/', $normalizedPath); if ($normalizedPath === '') return ''; if (preg_match('/^https?:\/\//i', $normalizedPath)) return $normalizedPath; $normalizedPath = preg_replace('#^/?public/#', '', $normalizedPath); $normalizedPath = preg_replace('#^/?storage/#', '', $normalizedPath); $normalizedPath = ltrim($normalizedPath, '/'); return route('attachment.show', ['path' => $normalizedPath]); }; $isImage = function($filePath) { $pathOnly = parse_url(str_replace('\\', '/', trim((string) $filePath)), PHP_URL_PATH) ?? $filePath; $ext = strtolower(pathinfo($pathOnly, PATHINFO_EXTENSION)); return in_array($ext, ['jpg','jpeg','png','gif','webp','jfif','heic','heif']); }; $allDocs = collect($allDocs)->filter(function($doc) { $f = trim((string) ($doc->file ?? '')); return $f !== '' && $f !== '0' && strtolower($f) !== 'null'; }); $modalId = isset($modalId) ? $modalId : 'allDocsModal' . $detail->id; @endphp