@php // Logic Status Progress Bar $stages = ['OPEN', 'PICKUP', 'PROCESS', 'DEPART', 'ON DESTINATION', 'ON COURIER', 'DELIVERED']; $currentStatus = strtoupper($status); $currentIndex = 0; // Cari status eksak $found = array_search($currentStatus, $stages); if ($found !== false) { $currentIndex = $found; } else { // Cari status partial (misal: 'PROCESS (HUB)') foreach ($stages as $key => $stage) { if (str_contains($currentStatus, $stage)) { $currentIndex = $key; break; } } } @endphp
@foreach($stages as $key => $stage) @php // Tentukan class CSS berdasarkan urutan $stepClass = ''; if ($key < $currentIndex) { $stepClass = 'passed'; } elseif ($key == $currentIndex) { $stepClass = ($currentStatus == 'DELIVERED') ? 'success' : 'active'; } @endphp
@if($key < $currentIndex) @elseif($key == $currentIndex && $currentStatus == 'DELIVERED') @elseif($key == $currentIndex) @else {{ $key + 1 }} @endif
{{ $stage }}
@endforeach
Riwayat Perjalanan
@php // Membalik urutan data riwayat agar status TERBARU selalu ada di PALING ATAS // Hal ini juga memperbaiki bug indikator warna yang salah sasaran $historyList = collect($history)->reverse()->values(); @endphp @foreach($historyList as $index => $hist) @php // Karena data sudah dibalik, status terbaru pasti ada di index 0 ($loop->first) $isLatest = $loop->first; $isDelivered = ($isLatest && strtoupper($hist->status) == 'DELIVERED'); // Tentukan class timeline history (Hijau untuk Delivered, Merah untuk Active saat ini) $historyClass = ''; if ($isDelivered) { $historyClass = 'success'; } elseif ($isLatest) { $historyClass = 'active'; } @endphp
{{ $hist->last_update ? \Carbon\Carbon::parse($hist->last_update)->format('d M Y') : '-' }} {{ $hist->last_update ? \Carbon\Carbon::parse($hist->last_update)->format('H:i') : '-' }} WIB
{{ $hist->status }}
{{ $hist->status_description }}
@if(strtoupper($hist->status) == 'DELIVERED' && !empty($hist->url_img)) Lihat Bukti Foto @endif
@endforeach @if(count($historyList) == 0)
Belum ada data riwayat tersedia.
@endif