@isset($basicData['foto']) @php $photos = $formFoto['upload_foto'] ?? []; if (!is_array($photos)) { $photos = []; } $groupedPhotos = collect($photos)->groupBy('category'); $mainPhotos = $groupedPhotos->filter(fn($_, $key) => strtolower($key) !== 'lainnya'); // Definisikan urutan yang diinginkan $desiredOrder = [ 'PETA LOKASI', 'GAMBAR SITUASI / SURAT UKUR', 'BLAD TATA KOTA', 'FOTO JAMINAN', 'DOKUMEN PENDUKUNG' ]; // Urutkan ulang $mainPhotos sesuai urutan yang diinginkan $orderedMainPhotos = collect(); foreach ($desiredOrder as $category) { if ($mainPhotos->has($category)) { $orderedMainPhotos->put($category, $mainPhotos->get($category)); } } // Tambahkan kategori lain yang tidak ada dalam urutan yang diinginkan foreach ($mainPhotos as $category => $photos) { if (!in_array($category, $desiredOrder)) { $orderedMainPhotos->put($category, $photos); } } $mainPhotos = $orderedMainPhotos; $otherPhotos = $groupedPhotos->get('lainnya', collect()); @endphp @if ($groupedPhotos->isEmpty())

Tidak ada foto yang tersedia.

@else @foreach ($mainPhotos as $category => $photos) @if($category=='DOKUMEN PENDUKUNG') @php continue; @endphp @endif @php $groupedBySubcategory = $photos->groupBy('sub'); @endphp @foreach ($groupedBySubcategory as $subcategory => $subPhotos) @if (count($subPhotos) > 0) @foreach ($subPhotos->chunk(2) as $chunkedPhotos) @foreach ($chunkedPhotos as $item) @php // Logika fallback untuk path file $originalPath = $item['path']; $fallbackPath = null; // Jika file asli tidak ditemukan, buat fallback path if ($statusLpj == 1) { $fullOriginalPath = storage_path('app/public/' . $originalPath); if (!file_exists($fullOriginalPath)) { // Ekstrak bagian akhir path (contoh: 251051/251051_2_2.png) $pathParts = explode('/', $originalPath); if (count($pathParts) >= 2) { $lastTwoParts = array_slice($pathParts, -2); $fallbackPath = 'surveyor/001/' . implode('/', $lastTwoParts); } } } // Tentukan path yang akan digunakan $pathToUse = ($fallbackPath && $statusLpj == 1 && file_exists(storage_path('app/public/' . $fallbackPath))) ? $fallbackPath : $originalPath; $filePath = $statusLpj == 1 ? storage_path('app/public/' . $pathToUse) : asset('storage/' . $pathToUse); $extension = strtolower(pathinfo($pathToUse, PATHINFO_EXTENSION)); $isImage = in_array($extension, [ 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp', 'tiff', ]); $isPdf = $extension === 'pdf'; @endphp @if ($statusLpj == 1) @if ($isImage && $filePath) @endif @elseif ($statusLpj != 1) @endif @endforeach @if (count($chunkedPhotos) < 2) @endif

{{ $category }} - @isset($subcategory) @if (trim($subcategory) !== '') {{ $subcategory }} - @endif @endisset {{ $item['name'] ?? '' }}

{{ $pathToUse }}

{{ $category }} - @isset($subcategory) @if (trim($subcategory) !== '') {{ $subcategory }} - @endif @endisset {{ $item['name'] ?? '' }}

@if ($statusLpj || file_exists(public_path('storage/' . $item['path']))) @if ($isImage) {{ $item['path'] }} @elseif ($isPdf) ⬇️ Unduh File PDF @else ⬇️ Unduh File @endif @endif @isset($item['description'])

{{ $item['description'] }}

@endisset
@endforeach @endif @endforeach @endforeach @if (!$otherPhotos->isEmpty()) @dd(!$otherPhotos->isEmpty()) @foreach ($otherPhotos->groupBy('sub') as $subcategory => $subPhotos) @if (count($subPhotos) > 0) @foreach ($subPhotos->chunk(2) as $chunkedPhotos) @foreach ($chunkedPhotos as $item) @php $filePath = $statusLpj == 1 ? storage_path('app/public/' . $item['path']) : asset('storage/' . $item['path']); $extension = strtolower(pathinfo($item['path'], PATHINFO_EXTENSION)); $isImage = in_array($extension, [ 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp', 'tiff', ]); $isPdf = $extension === 'pdf'; @endphp @if ($statusLpj == 1) @if ($isImage && $filePath) @endif @elseif ($statusLpj != 1) @endif @endforeach @if (count($chunkedPhotos) < 2) @endif

{{ $category }} - @isset($subcategory) @if (trim($subcategory) !== '') {{ $subcategory }} - @endif @endisset {{ $item['name'] ?? '' }}

{{ $item['path'] }}

Lainnya - @isset($subcategory) @if (trim($subcategory) !== '') {{ $subcategory }} - @endif @endisset {{ $item['name'] ?? '' }}

@if ($statusLpj || file_exists(public_path('storage/' . $item['path']))) @if ($isImage) {{ $item['path'] }} @elseif ($isPdf) ⬇️ Unduh File PDF @else ⬇️ Unduh File @endif @endif @isset($item['description'])

{{ $item['description'] }}

@endisset
@endforeach @endif @endforeach @endif @endif @endisset