return $this->model->whereHas('mills', function($query) use ($gradeIds) { $query->whereHas('pulp', function ($query) use ($gradeIds) { $query->whereIn('grade_id', $gradeIds); }); })->with(['mills' => function($query) { $query->with('pulp'); }])->get();