Driver | @foreach ($dates as $date)
{{ \Carbon\Carbon::parse($date)->format('j') }} {{ \Carbon\Carbon::parse($date)->format('D') }} |
@endforeach
Total |
---|---|---|
{{ $driver->name }} @if (auth()->id() === $driver->id) It's you @endif |
@php $total = 0; @endphp
@foreach ($dates as $date)
@php
$today = Carbon\Carbon::today();
$dateObj = \Carbon\Carbon::parse($date);
$dateString = $date->toDateString();
$attendance = $driver->attendances->first(function ($record) use ($dateString) {
return $record->attendance_date->toDateString() === $dateString;
});
$statusLabels = [
'P' => '',
'H' => '',
'D' => '',
'HD' => '',
'L' => '',
'A' => '',
'LV' => '',
];
$status = $attendance->status ?? ($dateObj->lte($today) ? 'A' : null);
$icon = $status ? ($statusLabels[$status] ?? '-') : '-';
if ($status === 'P') {
$total++;
}
@endphp
{!! $icon !!} | @endforeach{{ $total }}/{{ \Carbon\Carbon::parse($dates->first())->daysInMonth }} |