@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, 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 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; for ($i = 0; $i < 10; $i++) { $img_id .= $characters[mt_rand(0, strlen($characters) - 1)]; } @endphp @if (substr($string, 0, 3) == 'IMG')
|
@elseif (substr($string, 0, 3) == 'CDT')
{{ $detail->$string }} | @elseif (substr($string, 0, 3) == 'CST'){{ $detail->$string }} | @else @php $cellVal = trim((string) ($detail->$string ?? '')); @endphp@if (isset($dmenu) && $dmenu === 'rpgsap' && strtolower($string) === 'lampiran' && $cellVal !== '') @php $isUrl = filter_var($cellVal, FILTER_VALIDATE_URL); $assetPath = $cellVal; // Try normalize common relative formats to storage/.. if (!$isUrl) { if (strpos($assetPath, 'storage/') === false && strpos($assetPath, '/') !== 0) { // values like "PDF/.." or "pdf\\.." if (stripos($assetPath, 'pdf') === 0 || stripos($assetPath, 'pdf/') === 0) { $assetPath = 'storage/' . ltrim($assetPath, '/\\'); } } } // Prepare candidates to check on filesystem $candidates = []; if ($isUrl) { $fileExists = true; // cannot check remote file; assume exists } else { $candidates[] = $assetPath; // e.g. storage/PDF/... // also try raw value (in case it already contains public path) $candidates[] = ltrim($cellVal, '/\\'); // try with storage/ prefix if not present if (strpos($cellVal, 'storage/') === false) { $candidates[] = 'storage/' . ltrim($cellVal, '/\\'); } $fileExists = false; foreach ($candidates as $cand) { if (file_exists(public_path($cand))) { $fileExists = true; $assetPath = $cand; break; } } } // final URL for link if ($isUrl) { $url = $cellVal; } else { $url = asset($assetPath); } @endphp @if ($fileExists) View PDF @else {{ $cellVal }} File not found @endif @else @if (isset($dmenu) && $dmenu === 'rpgsap' && (strtolower($string) === 'no po' || strtolower($string) === 'no_po' || strtolower($string) === 'po' || strtolower($string) === 'ebeln' || strtolower($string) === 'po_number') && $cellVal !== '') {{ $detail->$string }} @else {{ $detail->$string }} @endif @endif | @endif @php $i++; @endphp @endforeach