skip to Main Content

Cascade delete in Laravel

I have a example of cascade delete but it looks too big and complicated, is there a way to shorten this code? protected static function boot() { parent::boot(); static::deleted(function ($parent) { // $versions = $parent->game_versions(); $versions = $parent->game_versions; foreach($versions as…

VIEW QUESTION

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
Back To Top
Search