public static function download($idUser, $idCourse) { $app = \Slim\Slim::getInstance(); if (!Course::find($idCourse)) { $app->response->setStatus(404); return json_encode("Course not found"); } if (!Enrollment::where('user_id', '=', $idUser)->where('course_id', '=', $idCourse)->count()) { $app->response->setStatus(401); return json_encode("You have to enroll this course first."); } FileController::downloadCourse($idCourse); }