これを参照してください
$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();