public function courses()
 {
     $user = Sentry::getUser();
     $student = Student::where('email', $user->email)->first();
     if (empty($student)) {
         throw new Exception('Estudiante no encontrado.');
     }
     $courses = $student->courses()->with('professor')->with('venue')->with('subject')->get();
     return Response::json($courses);
 }
Example #2
0
 public function signup($course_id)
 {
     $user = Sentry::getUser();
     $student = Student::where('email', $user->email)->first();
     if (empty($student)) {
         throw new ModelNotFoundException('Estudiante no encontrado');
     }
     $course = Course::findOrFail($course_id);
     try {
         $course->students()->attach($student->id, ['payment_status' => 'not_paid']);
     } catch (QueryException $e) {
         throw new StudentIsAlreadySignupException("Ya estás registrado en este curso");
     }
 }