{!! $print['head'] !!} @foreach ($reports as $report) @php $grouped = collect(); if (isset($report)) { // $grouped = $report->transactions->groupBy('process_id'); $grouped = $report->transactions ->groupBy('supervisor_id') ->map(function ($groupedBySupervisor) { return $groupedBySupervisor->groupBy('process_id'); }); } dd($grouped); @endphp @foreach ($shifts as $shift) @endforeach @foreach ($grouped as $item) @php $rowTotal = 0; @endphp @foreach ($shifts as $shift) @php $quantity = $item->where('shift_id', $shift->id)->sum('quantity'); $rowTotal += $quantity; @endphp @endforeach @endforeach @php $colTotal = 0; @endphp @foreach ($shifts as $shift) @php $quantity = $grouped->sum(function ($item) use ($shift) { return $item->where('shift_id', $shift->id)->sum('quantity'); }); $colTotal += $quantity; @endphp @endforeach
Process {{ date('h:i A', strtotime($shift->start_time)) }} - {{ date('h:i A', strtotime($shift->end_time)) }} Total Remarks
{{ $item[0]->getProcess->name ?? '' }}{{ $quantity }}{{ $rowTotal }}
Total{{ $quantity }}{{ $colTotal }}
@endforeach