@php $paths = []; $rawImages = $item->spirometry_images ?? null; if ($rawImages) { $decoded = is_array($rawImages) ? $rawImages : json_decode($rawImages, true); if (is_array($decoded)) { foreach ($decoded as $p) { if ($p) { $paths[] = $p; } } } } if ($item->result_file_path && !in_array($item->result_file_path, $paths, true)) { array_unshift($paths, $item->result_file_path); } $primaryPath = $item->result_file_path ?: $paths[0] ?? null; $additionalPaths = []; if ($primaryPath) { foreach ($paths as $p) { if ($p && $p !== $primaryPath) { $additionalPaths[] = $p; } } } $patientLabel = $item->appointment?->patient?->full_name ?? ''; @endphp @if ($primaryPath) @php $fileExtension = strtolower(pathinfo($primaryPath, PATHINFO_EXTENSION)); $fileUrl = Storage::url($primaryPath); $viewerTitle = 'Hasil Spirometry - ' . $patientLabel; @endphp