Laravel – Splitting up query with join, using load in strict mode
I wrote a code something like this: $bunnies = Bunny::with(['carrots' => function ($query) use ($request){ if (empty($request->carrotStatus)) return; $query->where('status', $request->carrotStatus); }, 'owner']) ->select('bunnies.*') ->join('carrots', 'bunnies.id', '=', 'carrots.bunny_id') ->where(function (Builder $query) use ($request){ if (empty($request->carrotStatus)) return; $query->where('carrots.status', $request->carrotStatus); }) ->where(function (Builder…