@extends('layouts.app', ['class' => 'g-sidenav-show bg-gray-100']) {{-- section content --}} @section('content') @include('layouts.navbars.auth.topnav', ['title' => ''])
| No | {{-- set table header --}} @foreach ($table_result as $result) @php $sAsArray = array_keys((array) $result); $i = 0; @endphp @endforeach @foreach ($sAsArray as $header) @if (substr($header, 0, 4) == 'HDN_') {{-- Hidden column: tidak tampilkan sebagai header --}} @elseif (substr($header, 0, 3) == 'IMG'){{ substr($header, 4) }} | @elseif (substr($header, 0, 3) == 'CDT'){{ substr($header, 6) . '-' . substr($header, 3, 2) }} | @elseif (substr($header, 0, 3) == 'CST'){{ substr($header, 4) }} | @else{{ $header }} | @endif @php $i++; @endphp @endforeach
|---|---|---|---|---|
| {{ $loop->iteration }} | @foreach ($table_result as $result) @php $field = array_keys((array) $result); $i = 0; @endphp @endforeach @foreach ($field as $header) @php $string = $header; $img_id = ''; $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUFGHIJKLMNOPQRSTUVWXYZ'; for ($i = 0; $i < 10; $i++) { $img_id .= $characters[mt_rand(0, strlen($characters) - 1)]; } @endphp @if (substr($string, 0, 4) == 'HDN_') {{-- Hidden column: tidak render sebagai, data sudah di data-attribute | |||
|
@php
$rawImages = trim((string) ($detail->$string ?? ''));
$imageItems = [];
if ($rawImages !== '') {
$decodedImages = null;
if (str_starts_with($rawImages, '[')) {
$decodedImages = json_decode($rawImages, true);
}
if (is_array($decodedImages)) {
$imageItems = $decodedImages;
} else {
$imagePaths = preg_split('/\s*(?:\|\||\||,)\s*/', $rawImages, -1, PREG_SPLIT_NO_EMPTY);
foreach ($imagePaths as $imagePath) {
$parts = explode('@@', (string) $imagePath, 2);
$imageItems[] = [
'date' => $parts[0] !== $imagePath ? trim($parts[0]) : '',
'path' => trim($parts[1] ?? $parts[0]),
];
}
}
}
$imageItems = array_values(array_filter(array_map(function ($item) {
if (is_array($item)) {
return [
'date' => trim((string) ($item['date'] ?? '')),
'path' => trim((string) ($item['path'] ?? '')),
];
}
$rawItem = trim((string) $item);
if ($rawItem === '') {
return null;
}
$parts = explode('@@', $rawItem, 2);
return [
'date' => trim($parts[0] ?? ''),
'path' => trim($parts[1] ?? $parts[0]),
];
}, $imageItems)));
$uniqueImageItems = [];
$seenImagePaths = [];
foreach ($imageItems as $imageItem) {
$pathKey = $imageItem['path'] ?? '';
// skip empty, '0', 'null', or paths that are purely numeric (invalid)
if (
$pathKey === ''
|| $pathKey === '0'
|| strtolower($pathKey) === 'null'
|| (is_numeric($pathKey) && strpos($pathKey, '/') === false)
|| in_array($pathKey, $seenImagePaths, true)
) {
continue;
}
$seenImagePaths[] = $pathKey;
$uniqueImageItems[] = $imageItem;
}
$imageItems = $uniqueImageItems;
$getImageUrl = function ($path) {
$normalizedPath = str_replace('\\', '/', trim((string) $path));
if ($normalizedPath === '') {
return '';
}
if (preg_match('/^https?:\/\//i', $normalizedPath)) {
return $normalizedPath;
}
$normalizedPath = preg_replace('#^/?public/#', '', $normalizedPath);
$normalizedPath = preg_replace('#^/?storage/#', '', $normalizedPath);
return route('attachment.show', ['path' => ltrim($normalizedPath, '/')]);
};
$galleryId = 'gallery_' . $img_id;
$carouselId = 'carousel_' . $img_id;
@endphp
@if (count($imageItems) > 0)
@foreach ($imageItems as $imageIndex => $imageItem)
@php
$imageUrl = $getImageUrl($imageItem['path']);
$isPdf = strtolower(pathinfo($imageItem['path'], PATHINFO_EXTENSION)) === 'pdf';
@endphp
@if ($isPdf)
PDF
@else
@else
@php
$rpnphdNpId = $detail->HDN_non_periodic_id ?? null;
$hasPengerjaan = !empty($detail->HDN_has_pengerjaan) && (int) $detail->HDN_has_pengerjaan === 1;
@endphp
@if ($dmenu === 'rpnphd' && $rpnphdNpId && $hasPengerjaan)
Kosong
@else
-
@endif
@endif
|
@elseif (substr($string, 0, 3) == 'CDT'))
{{ $detail->$string }} | @elseif (substr($string, 0, 3) == 'CST'){{ $detail->$string }} | @else{{ $detail->$string }} | @endif @php $i++; @endphp @endforeach