skip to Main Content

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',…

VIEW QUESTION

Laravel – Attempt to read property "episodes" on null

I wrote a code that sums the number of minutes of several videos together. But it shows the following error: Attempt to read property "episodes" on null public function setCourseTime($episode) { $course = $episode->course; $course->time = $this->getCourseTime($course->episodes->pluck('time')); $course->save(); } Model…

VIEW QUESTION
Back To Top
Search