public function store(CourseRequest $request) { $course = new Course($request->only(['name'])); $course->save(); $course->users()->sync($request->input('users')); $course->teachers()->sync($request->input('teachers')); session()->flash('success', 'El curso se ha creado.'); return redirect()->route('admin.course.edit', $course->id); }