public function index($handbook_id, $grade_id) { $handbook = CourseHandbook::find($handbook_id); // Get all courses and grades to fill the selects $courses = Course::all(); $grades = Grade::all(); // Select the grade and its courses associated in the current handbook $current_grade = Grade::find($grade_id); $current_courses = CourseGrade::where('course_handbook_id', $handbook_id)->where('grade_id', $grade_id)->get(['course_id']); $current_courses = $this->convertToCourseCollection($current_courses); return view('configuracion.asignar-cursos')->with(compact(['handbook', 'courses', 'grades', 'current_courses', 'current_grade'])); }
public function destroy($id) { $course_handbook = CourseHandbook::find($id); $relations = $course_handbook->course_grade_relations; if ($relations->count() > 0) { return back()->with('error', 'No es posible eliminar una malla curricular con cursos asignados.'); } $school_years = $course_handbook->school_years; if ($school_years->count() > 0) { return back()->with('error', 'No es posible eliminar una malla curricular si está asignada a un año lectivo.'); } $course_handbook->delete(); return back(); }