/** * Display a listing of the resource. * * @return Response */ public function index() { $candidates = Candidates::with("user", "experience")->whereHas('user', function ($q) { $q->where('role', 1); })->get(); // shoud thake from candidates return response()->json($candidates); }