| # |
@if(auth()->user()->role === 'admin')
Montir |
@endif
Tanggal Inspeksi |
Status / Progress |
Aksi |
@forelse($inspeksi as $index => $item)
@php
$totalSteps = 20;
$currentStep = $item->current_step ?? 0;
$progress = min(($currentStep / $totalSteps) * 100, 100);
$status = $item->status ?? 'pending';
$badgeColor = match($status) {
'pending' => 'bg-warning',
'draft' => 'bg-primary',
'selesai' => 'bg-success',
'suspended' => 'bg-danger',
default => 'bg-secondary',
};
// 🔒 AMAN: relasi cekAlat bisa null
$cekAlat = $item->cekAlat ?? collect();
// ✅ FOTO ADA JIKA ADA ISI ARRAY FOTO
$hasFoto = $cekAlat->filter(function ($cek) {
return !empty($cek->foto)
&& is_array($cek->foto)
&& count($cek->foto) > 0;
})->count() > 0;
@endphp
| {{ $inspeksi->firstItem() + $index }} |
@if(auth()->user()->role === 'admin')
{{ $item->montir->name ?? '-' }}
|
@endif
{{ $item->inspection_date
? \Carbon\Carbon::parse($item->inspection_date)->format('d-m-Y')
: '-' }}
|
{{-- STATUS & PROGRESS --}}
{{ ucfirst($status) }}
{{-- ✅ HANYA TAMPIL JIKA FOTO ADA --}}
@if($hasFoto)
Foto alat sudah diupload
@endif
{{-- PROGRESS BAR --}}
Step: {{ $currentStep }} / {{ $totalSteps }}
|
{{-- AKSI --}}
{{-- DETAIL --}}
{{-- EDIT --}}
@if($status !== 'selesai')
@endif
{{-- HAPUS --}}
{{-- APPROVE (ADMIN + FOTO ADA) --}}
@if(auth()->user()->role === 'admin' && $status === 'pending' && $hasFoto)
@endif
{{-- SUSPEND (ADMIN + FOTO BELUM ADA) --}}
@if(auth()->user()->role === 'admin' && !$hasFoto && $status !== 'selesai')
@endif
|
@empty
|
Belum ada data inspeksi
|
@endforelse
{{-- PAGINATION --}}
{{ $inspeksi->withQueryString()->links() }}