コード例 #1
0
ファイル: User.php プロジェクト: abhijith444/enroll
 function getAvailableSections()
 {
     $enrollments = Enrollment::where('student_id', '=', $this->id)->get()->toArray();
     $enrollment_ids = array_column($enrollments, 'id');
     $section_ids = array_column($enrollments, 'section_id');
     $sections_enrolled = Section::whereIn('id', $section_ids)->get()->toArray();
     $courses_enrolled = array_column($sections_enrolled, 'course_id');
     $sections_enrolled_timecode = array_column($sections_enrolled, 'time_code');
     $sections_enrolled_days = array_column($sections_enrolled, 'days');
     $sections_enrolled_timeflags = [];
     for ($i = 0; $i < count($sections_enrolled_timecode); $i++) {
         $sections_enrolled_timeflags[] = $sections_enrolled_days[$i] . $sections_enrolled_timecode[$i];
     }
     $sections_available = Section::whereNotIn('course_id', $courses_enrolled)->get()->toArray();
     $sections_available_ids = array_column($sections_available, 'id');
     $vsections_available = Vsection::whereIn('id', $sections_available_ids)->whereRaw('filled < capacity')->whereNotIn('time_flag', $sections_enrolled_timeflags)->get()->toArray();
     // print_r($section_ids);
     // foreach ($enrollments as $e) {
     // 	$enrollment_ids[] = $e->id;
     // }
     // dd($sections_enrolled);
     // dd($vsections_available);
     return $vsections_available;
 }