perbaikan kertas kerja, paparan, dan lampiran
This commit is contained in:
@@ -464,79 +464,147 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h4>Peta Objek dan Pembanding
|
||||
</h4>
|
||||
<h4>Peta Objek dan Pembanding</h4>
|
||||
|
||||
@php
|
||||
$fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat'];
|
||||
@php
|
||||
$fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat'];
|
||||
@endphp
|
||||
|
||||
// echo $dataForm;
|
||||
@php
|
||||
$imagePath = $dataform['foto_gistaru'];
|
||||
@endphp
|
||||
<img
|
||||
src="{{ asset('public/' . $imagePath) }}"
|
||||
alt=""
|
||||
class="max-w-full h-auto mx-auto"
|
||||
|
||||
@endphp
|
||||
>
|
||||
|
||||
@for ($i = 0; $i < count($fotoTypes); $i++)
|
||||
<img src="{{ isset($dataform[$fotoTypes[$i]]) ? asset('storage/' . $dataform[$fotoTypes[$i]]) : '#' }}"
|
||||
alt="{{ $fotoTypes[$i] }}" style="max-width: 40rem;">
|
||||
@endfor
|
||||
<div class="grid grid-cols-4 gap-4">
|
||||
@forelse ($fotoTypes as $type)
|
||||
<div class="text-center">
|
||||
@php
|
||||
$imagePath = $dataform[$type];
|
||||
@endphp
|
||||
|
||||
<h4>FOTO OBJEK DAN DATA PEMBANDING</h4>
|
||||
|
||||
@foreach ($dataPembanding['data_pembanding'] as $item)
|
||||
<img src="{{ isset($item['foto_objek']) ? asset('storage/' . $item['foto_objek']) : '#' }}"
|
||||
alt="Foto Objek" style="max-width: 20rem;">
|
||||
<p style="text-center">Data Pembanding {{ $loop->iteration }}</p>
|
||||
@endforeach
|
||||
|
||||
|
||||
@php
|
||||
$dataFoto = json_decode($data->foto_form, true);
|
||||
@endphp
|
||||
<h4>FOTO OBJEK</h4>
|
||||
|
||||
@php
|
||||
$images = [];
|
||||
|
||||
// Rute Menuju Lokasi
|
||||
foreach ($dataFoto['rute_menuju_lokasi'] ?? [] as $rute) {
|
||||
$images[] = $rute['foto_rute'] ?? null;
|
||||
}
|
||||
|
||||
// Objek Jaminan
|
||||
foreach ($dataFoto['object_jaminan'] ?? [] as $objek) {
|
||||
$images[] = $objek['foto_objek'] ?? null;
|
||||
}
|
||||
|
||||
// Lingkungan
|
||||
foreach ($dataFoto['lingkungan'] ?? [] as $lingkungan) {
|
||||
$images[] = $lingkungan['foto_lingkungan'] ?? null;
|
||||
}
|
||||
|
||||
// Lantai Unit
|
||||
foreach ($dataFoto['foto_lantai_unit'] ?? [] as $lantai) {
|
||||
$images[] = $lantai['foto_lantai_unit'] ?? null;
|
||||
}
|
||||
|
||||
// Tambahan foto lainnya
|
||||
$images[] = $dataFoto['foto_basement'] ?? null;
|
||||
$images[] = $dataFoto['foto_gerbang'] ?? null;
|
||||
$images[] = $dataFoto['pendamping'] ?? null;
|
||||
|
||||
// Filter null values
|
||||
$images = array_filter($images);
|
||||
@endphp
|
||||
|
||||
<div class="row">
|
||||
@foreach ($images as $image)
|
||||
<img src="{{ asset('storage/' . $image) }}" alt="Foto Survey"
|
||||
style="
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
object-fit: cover;
|
||||
margin: 10px;
|
||||
"
|
||||
onerror="this.src='{{ asset('default-image.png') }}'">
|
||||
@endforeach
|
||||
{{-- @if ($imagePath && Storage::exists($imagePath)) --}}
|
||||
<img
|
||||
src="{{ asset('public/' . $imagePath) }}"
|
||||
alt="{{ $type }}"
|
||||
class="max-w-full h-auto mx-auto"
|
||||
onerror="this.src='{{ asset('default-image.png') }}'"
|
||||
>
|
||||
<p class="mt-2 text-sm">{{ Str::title(str_replace('_', ' ', $type)) }}</p>
|
||||
{{-- @else
|
||||
<div class="bg-gray-200 p-4 text-center">
|
||||
<p>Tidak ada gambar</p>
|
||||
</div>
|
||||
@endif --}}
|
||||
</div>
|
||||
@empty
|
||||
<p>Tidak ada tipe foto yang tersedia</p>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<h4 class="mt-6">FOTO OBJEK DAN DATA PEMBANDING</h4>
|
||||
|
||||
<div class="grid grid-cols-4 gap-4">
|
||||
@forelse ($dataPembanding['data_pembanding'] ?? [] as $index => $item)
|
||||
<div class="text-center">
|
||||
@php
|
||||
$fotoObjek = $item['foto_objek'];
|
||||
@endphp
|
||||
|
||||
@if ($fotoObjek && Storage::exists($fotoObjek))
|
||||
<img
|
||||
src="{{ asset('storage/' . $fotoObjek) }}"
|
||||
alt="Foto Objek Pembanding {{ $loop->iteration }}"
|
||||
class="max-w-full h-auto mx-auto"
|
||||
onerror="this.src='{{ asset('default-image.png') }}'"
|
||||
>
|
||||
<p class="mt-2 text-sm">Data Pembanding {{ $loop->iteration }}</p>
|
||||
@else
|
||||
<div class="bg-gray-200 p-4 text-center">
|
||||
<p>Tidak ada gambar pembanding</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@empty
|
||||
<p class="col-span-4">Tidak ada data pembanding</p>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<h4 class="mt-6">FOTO OBJEK</h4>
|
||||
|
||||
@php
|
||||
// Fungsi untuk mengumpulkan foto dengan pengecekan yang aman
|
||||
function collectSafeImages($data, $paths = []) {
|
||||
if (!is_array($data)) {
|
||||
return $paths;
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
// Jika array memiliki kunci foto
|
||||
if (isset($value['foto_rute'])) {
|
||||
$paths[] = $value['foto_rute'];
|
||||
}
|
||||
if (isset($value['foto_objek'])) {
|
||||
$paths[] = $value['foto_objek'];
|
||||
}
|
||||
if (isset($value['foto_lingkungan'])) {
|
||||
$paths[] = $value['foto_lingkungan'];
|
||||
}
|
||||
if (isset($value['foto_lantai_unit'])) {
|
||||
$paths[] = $value['foto_lantai_unit'];
|
||||
}
|
||||
|
||||
// Rekursif untuk nested array
|
||||
$paths = collectSafeImages($value, $paths);
|
||||
} elseif (is_string($value) && strpos($value, 'foto_') !== false) {
|
||||
$paths[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
// Decode foto form dengan penanganan error
|
||||
try {
|
||||
$dataFoto = json_decode($data->foto_form, true) ?? [];
|
||||
} catch (Exception $e) {
|
||||
$dataFoto = [];
|
||||
}
|
||||
|
||||
// Kumpulkan foto
|
||||
$images = collectSafeImages($dataFoto);
|
||||
|
||||
// Filter foto yang valid
|
||||
$validImages = array_filter($images, function($image) {
|
||||
return $image && Storage::exists($image);
|
||||
})
|
||||
|
||||
|
||||
|
||||
@endphp
|
||||
|
||||
<div class="grid grid-cols-4 gap-4">
|
||||
@forelse ($validImages as $image)
|
||||
<div class="text-center">
|
||||
<img
|
||||
src="{{ asset('storage/' . $image) }}"
|
||||
alt="Foto Survey"
|
||||
class="w-full h-64 object-cover"
|
||||
onerror="this.src='{{ asset('default-image.png') }}'"
|
||||
>
|
||||
</div>
|
||||
@empty
|
||||
<div class="col-span-4 text-center bg-gray-200 p-4">
|
||||
<p>Tidak ada foto objek yang tersedia</p>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user