@php // Kolom waktu yang disembunyikan karena sudah digabung $skipAtCols = ['tested_at', 'checked_at', 'supervisor_at']; // Pasangan kolom "by" dengan waktu $byPairs = [ 'tested_by' => 'tested_at', 'checked_by' => 'checked_at', 'supervisor_by'=> 'supervisor_at', ]; @endphp {{-- Header baseCols (tanpa *_at) --}} @foreach ($baseCols as $title => $col) @if(in_array($col, $skipAtCols)) @continue @endif @endforeach {{-- Header Properties --}} @foreach ($propCols as $title => $alias) @endforeach {{-- Header Parameter Mesin (tanpa Num/Txt) --}} @foreach ($paramCols as $title => $aliases) @endforeach @foreach ($rows as $r) {{-- BaseCols: gabungkan *_by dengan *_at --}} @foreach ($baseCols as $title => $col) @if(in_array($col, $skipAtCols)) @continue @endif @if(array_key_exists($col, $byPairs)) @php $name = $r->{$col} ?? ''; $atField = $byPairs[$col]; $atRaw = $r->{$atField} ?? null; $timeStr = null; if (!empty($atRaw)) { try { $timeStr = \Carbon\Carbon::parse($atRaw)->format('H:i:s'); } catch (\Throwable $e) { $timeStr = substr((string)$atRaw, 11, 8); // fallback } } @endphp @else @endif @endforeach {{-- Property --}} @foreach ($propCols as $alias) @endforeach {{-- Parameter Mesin --}} @foreach ($paramCols as $aliases) @endforeach @endforeach
{{ $title }}{{ $title }}{{ $title }} {{ $title }}
@if(!empty($name) && !empty($timeStr)) {{ $name }} at {{ $timeStr }} @elseif(!empty($name)) {{ $name }} @else - @endif {{ $r->{$col} ?? '-' }}{{ $r->{$alias} ?? '-' }}{{ $r->{$aliases[0]} ?? '-' }} {{ $r->{$aliases[1]} ?? '-' }}