Пример #1
0
 public function menroll($student_ids, $sid)
 {
     $section_id = Request::input('id');
     $user = Auth::user();
     $k = Enrollment::create(['student_id' => $user->id, 'section_id' => $section_id]);
     return $k;
 }
Пример #2
0
 public static function enroll($uid, $sid)
 {
     $enrollment = Enrollment::create(['student_id' => $uid, 'section_id' => $sid]);
     $section = Section::find($sid);
     $section->filled = $section->filled + 1;
     $section->save();
     User::find($uid)->touch();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     if (!Input::get('attendee_id') or !Input::get('program_id')) {
         return $this->respondUnprocessableEntity('Parameters failed validation for an enrollment.');
     }
     try {
         $attendee = Attendee::findOrFail(Input::get('attendee_id'));
     } catch (ModelNotFoundException $e) {
         return $this->respondUnprocessableEntity('Attendee provided does not exist.');
     }
     try {
         $program = Program::findOrFail(Input::get('program_id'));
     } catch (ModelNotFoundException $e) {
         return $this->respondUnprocessableEntity('Program provided does not exist.');
     }
     $existingEnrollment = Enrollment::where('attendee_id', $attendee->id)->where('program_id', $program->id)->whereNull('enrollments.deleted_at')->get();
     if (count($existingEnrollment)) {
         return $this->respondUnprocessableEntity('The enrollment of the attendee to the program already exists.');
     }
     //We pass validation. Now add the enrollment.
     Enrollment::create(Input::all());
     return $this->respondCreated('Enrollment created successfully.');
 }