Laravel – groupBy in Controller Index function
I have data that I'm trying to groupBy a field on index function public function index() { abort_if(Gate::denies('workstep_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $thisUser = Auth::user(); $worksteps = Workstep::with(['site_id'])->where('site_id', $thisUser->site_id)->get(); return view('admin.worksteps.process', compact('worksteps')); } Adding ->groupBy('subprocess_id'); before->get(); As below $worksteps = Workstep::with(['site_id'])->where('site_id',…