/** * Bootstrap the application services. * * @return void */ public function boot() { \View::composer('*', function ($view) { $allCourses = \App\Course::with('requirements')->orderBy('course_name', 'ASC')->get()->toArray(); $view->with('user', \Auth::user())->with('allCourses', $allCourses); }); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($semester = null, $year = null) { $user = Auth::user(); $split = explode(" ", $user->role->name); $role_area = $split[count($split) - 1]; $areas = Area::with('professors')->get()->toArray(); $profe = Professor::with('areas')->get()->toArray(); $prof_areas = array(); foreach ($profe as $prof) { $prof_areas[$prof['id']] = $prof['areas']; } $collection = collect($areas); $area_professors = $collection->keyBy('name')->toArray(); // TODO: Pasar esto a un Helper if ($semester == null) { \Carbon\Carbon::now()->month >= 5 ? $semester = 2 : ($semester = 1); } $year == null ? $year = \Carbon\Carbon::now()->year : ($year = $year); $courses = Course::with('area')->get()->toArray(); if ($role_area == "Administrador") { $professors = Professor::all()->toArray(); //TODO: Pasar esto a un scope $unasigned_courses = Course::with('area')->where('taken', 0)->where('semester', $semester)->where('year', $year)->get(); $asigned_courses = Course::with('area')->where('taken', 1)->where('semester', $semester)->where('year', $year)->get(); } else { $professors = Area::with('professors')->where('name', $role_area)->get()->toArray()[0]["professors"]; $area = Area::where('name', $role_area)->first(); $unasigned_courses = Course::where('taken', 0)->where('area_id', $area->id)->where('semester', $semester)->where('year', $year)->get(); $asigned_courses = Course::where('taken', 1)->where('area_id', $area->id)->where('semester', $semester)->where('year', $year)->get(); } $professorCourse = array(); foreach ($courses as $course) { if (Schedule::where('course_id', $course['id'])->first() != null) { $professorId = Schedule::where('course_id', $course['id'])->first()->professor_id; $professorCourse[$course['id']] = Professor::where('id', $professorId)->first()->name; } } return view('schedules.index', compact('area_professors', 'prof_areas', 'professors', 'courses', 'professorCourse', 'unasigned_courses', 'asigned_courses', 'year', 'semester')); }
public function getCourse() { $course = Course::with('course_id', $this->course_id); return $course; }
public function getAllCourses() { return Course::with('holes.tees', 'teeSets.teeType', 'teeSets.tees')->get(); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $course = Course::with('tests', 'tests.questions')->has('tests.questions', '>', 0)->published()->findOrFail($id); return view('course.show', ['course' => $course]); }
public function getRecord($id) { return Course::with('college')->find($id); }
public function getCourses() { $courses = Course::with('college')->get(); return view('admin.coursesList', compact('courses')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $courses = Course::with('area')->get(); return view('courses.index', compact('courses')); }
public function documentsValidated($id, $value) { $course = Course::with(['users' => function ($query) { $query->where('level', 1); }, 'manager'])->find($id); if (empty($course)) { Flash::error('Ce cours n\'existe pas.'); return abort(404); } if (Auth::user()->level_id <= 3 && !$course->users->contains(Auth::user())) { Flash::error('Vous n\'avez pas les droits suffisants.'); return Redirect::back(); } if ($value != 0 && $value != 1) { Flash::error('Requête invalide.'); return Redirect::back(); } $documents = Document::where('course_id', $id)->where('validated', $value)->with('author')->paginate(15); $filter = $value == 0 ? 'invalidés' : 'validés'; return view('admin.courses.documents', compact('documents', 'filter', 'course')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $course = Course::with('tests', 'tests.questions', 'tests.questions.answers')->findOrFail($id); foreach ($course->tests as $test) { foreach ($test->questions as $question) { foreach ($question->answers as $answer) { $answer->delete(); } $question->delete(); } $test->delete(); } $course->delete(); }