subMonths(1)->format('%B'); $employeeTotals = []; foreach ($data as $employee) { $recordsGrouped = is_array($employee->records) ? $employee->records : (array)$employee->records; $monthlyTotals = []; foreach ($recordsGrouped as $month => $attendances) { $tsec = 0; foreach ($attendances as $attendance) { if (!empty($attendance->duration)) { [$h, $m, $s] = explode(':', $attendance->duration); $tsec += (int)$h * 3600 + (int)$m * 60 + (int)$s; } } $hours = floor($tsec / 3600); $minutes = floor(($tsec % 3600) / 60); $monthlyTotals[$month] = sprintf('%02d:%02d', $hours, $minutes); } $employeeTotals[$employee->id] = $monthlyTotals; } ?> @extends('app') @section('style') @endsection @section('content')
@if(empty($data) || count($data) == 0)

اطلاعاتی موجود نمیباشد

@else
@foreach($data as $employee) @endforeach
@foreach($data as $employee)

{{ $employee->name }}

کارکرد ماه قبل ({{ $previousMonthName }}): {{ $employeeTotals[$employee->id][$previousMonthName] ?? '00:00' }}
@php $recordsGrouped = is_array($employee->records) ? $employee->records : (array)$employee->records; @endphp @if(empty($recordsGrouped))
رکورد ترددی برای این شخص ثبت نشده است.
@else
@foreach(array_keys($recordsGrouped) as $month) @endforeach
@foreach($recordsGrouped as $month => $records) @endforeach @endif
@endforeach @endif
@endsection