Exemplo n.º 1
0
 private function requisites($type_id)
 {
     $instance = new Course();
     $relation = $this->getBelongsToManyCaller();
     $foreignKey = 'course_id';
     $otherKey = 'course_requisite_id';
     $table = 'requisites';
     $query = $instance->newQuery()->where('requisite_type_id', $type_id);
     return new BelongsToMany($query, $this, $table, $foreignKey, $otherKey, $relation);
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $data = json_decode(file_get_contents('database/scraped/coursesFall2016.json'));
     foreach ($data as $course) {
         // Requirements for course
         $faculty_id = Faculty::firstOrCreate(['name' => $course->faculty])->id;
         $name = substr($course->title, 0, -2);
         $number = $course->classNum;
         $credits = 3.0;
         // TODO delete this from the database
         $description = 'No description of the course.';
         // TODO maybe delete this from the database
         // end requirements for course
         // Requirements for scheduled_course
         $course_id = Course::firstOrCreate(['name' => $name, 'number' => $number, 'credits' => $credits, 'description' => $description, 'faculty_id' => $faculty_id])->id;
         $session_id = Session::firstOrCreate(['name' => $course->semester])->id;
         // end requirements for scheduled_course
         // Requirements for time_slot
         $scheduled_course_id = ScheduledCourse::firstOrCreate(['course_id' => $course_id, 'session_id' => $session_id])->id;
         if ($course->day != 'TBA') {
             $section = $course->section;
             $room = $course->room;
             $time_start = $course->timeBegin;
             $time_end = $course->timeEnd;
             $course_type_id = $this->getType($course->type)->id;
             //                $days = explode(';', preg_replace('/;$/', '', chunk_split($course->day, 2, ';')));
             $day = $course->day;
             //                    $day_of_week_id = $this->getDay($day)->id;
             TimeSlot::firstOrCreate(['scheduled_course_id' => $scheduled_course_id, 'section' => $section, 'room' => $room, 'time_start' => $time_start, 'time_end' => $time_end, 'day' => $day, 'course_type_id' => $course_type_id]);
         }
     }
     Model::reguard();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Course::destroy($id);
 }
Exemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Course::firstOrCreate(['name' => 'Software Process', 'description' => 'A class that teaches you how to develop software with a team.', 'faculty_id' => 2]);
     Course::firstOrCreate(['name' => 'Technical Writing', 'description' => 'Teaches you how to write things.', 'faculty_id' => 1]);
 }