вижте това
$courseId = 1;
$data = DB::table('student')->whereIn('id',function($query) use (courseId){
$query->select('student_id')
->from('student_course')->where('course_id', '=',$courseId);
})->get();
вижте това
$courseId = 1;
$data = DB::table('student')->whereIn('id',function($query) use (courseId){
$query->select('student_id')
->from('student_course')->where('course_id', '=',$courseId);
})->get();