@foreach ($site->units->sortBy(function ($item) {
if (Str::startsWith($item->unit_code, 'L-')) {
return 1;
}
if (Str::startsWith($item->unit_code, 'E-')) {
return 2;
}
if (Str::startsWith($item->unit_code, 'DT-')) {
return 3;
}
if (Str::startsWith($item->unit_code, 'S-')) {
return 4;
}
return 5;
}) as $item)
@php
$status =
$groupedBySiteShift[$item->id . '_' . $shift->id]->status_checklist ??
'Belum Checklist';
$map = [
'Baik' => ['color' => 'info', 'label' => 'Baik'],
'Cukup' => ['color' => 'success', 'label' => 'Cukup'],
'Rusak' => ['color' => 'danger', 'label' => 'Rusak'],
'Rusak Fatal' => ['color' => 'black', 'label' => 'Rusak Fatal'],
'Belum Checklist' => ['color' => 'primary', 'label' => 'Belum Checklist'],
'N/A' => ['color' => 'secondary', 'label' => 'N/A'],
];
$prefix = strtolower(strtok($item->unit_code, '-'));
if (strtolower($item->unit_code) === 'water truck') {
$prefix = 'wm';
}
$color = $map[$status]['color'];
$label = $map[$status]['label'];
$iconPath = asset("images/icon-unit/{$prefix}-{$color}.png");
@endphp
{{ $item->unit_code ?? 'Unknown' }}
{{ $label }}
@endforeach