コード例 #1
0
 private function extractSection($row, $section_info)
 {
     $sec = Section::firstOrNew($section_info);
     $values = ['term' => trim($row->childNodes->item(0)->textContent), 'section_number' => intval($row->childNodes->item(2)->textContent), 'credits' => intval($row->childNodes->item(3)->textContent), 'raw_times' => $this->DOMinnerHTML($row->childNodes->item(5)->childNodes->item(0)), 'raw_locations' => $this->DOMinnerHTML($row->childNodes->item(6)->childNodes->item(0)), 'instructor_id' => Instructor::firstOrCreate(['name' => $row->childNodes->item(4)->textContent])->id, 'section_type_id' => SectionType::firstOrCreate(['name' => $row->childNodes->item(8)->textContent])->id];
     foreach ($values as $key => $value) {
         $sec->{$key} = $value;
     }
     $this->createOrUpdateEnrollment($sec, $this->extractEnrollmentData($row, 10), 'current_enrollment_id');
     $this->createOrUpdateEnrollment($sec, $this->extractEnrollmentData($row, 13), 'waitlist_enrollment_id');
     return $sec;
 }
コード例 #2
0
 private function getAllByCourseId($courseId)
 {
     return Section::with('section_type', 'course.subject', 'enrollment_current', 'enrollment_waitlist', 'instructor')->whereCourseId($courseId);
 }