public function courseUpdate($id) { $colleges = College::All(); $course = Course::find($id); $majors = Major::where('course', $course->course_guid)->get(); return view('admin.update-course', compact('colleges', 'course', 'majors')); }
public function saveCourse(CreateCourseRequest $req) { $courseGuid = Uuid::uuid(); $course = new Course(); $course->course_guid = $courseGuid; $course->abrr = $req->abrr; $course->name = $req->name; $course->college = $req->college; $course->save(); $majors = json_decode($req->majors); if (count($majors) != 0) { foreach ($majors as $name) { $major = new Major(); $major->major_guid = Uuid::uuid(); $major->name = $name; $major->course = $courseGuid; $major->save(); } } }
public function getMajorsFromCourse($courseGuid) { $majors = Major::where('course', $courseGuid)->get(); return $majors; }