public static function addRequisites($course_id, $array, $type)
 {
     foreach ($array as $course_requisite_id) {
         $requisite = new Requisite();
         $requisite->course_id = $course_id;
         $requisite->course_requisite_id = $course_requisite_id;
         $requisite->requisite_type_id = $type;
         $requisite->save();
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->input();
     $course = Course::find($id);
     $course->name = $input['name'];
     $course->number = $input['number'];
     $course->credits = $input['credits'];
     $course->description = $input['description'];
     $course->faculty_id = $input['faculty_id'];
     $course->save();
     // Pre-requisite is id 1 in RequisiteType table
     if (isset($input['prerequisites'])) {
         Requisite::addRequisites($course->id, $input['prerequisites'], 1);
     }
     // Co-requisite is id 2 in RequisiteType table
     if (isset($input['corequisites'])) {
         Requisite::addRequisites($course->id, $input['corequisites'], 2);
     }
 }