@php $maxPunches = $data->max(function($item) { return count($item->punch_times); }); @endphp @for ($i = 1; $i <= $maxPunches; $i++) @endfor @php $counter = 1; @endphp @foreach ($data->groupBy('date') as $date => $records) @foreach ($records as $record) @foreach ($record->punch_times as $time) @endforeach @for ($i = count($record->punch_times); $i < $maxPunches; $i++) @endfor @endforeach @endforeach