예제 #1
0
 public function store(QuestionRequest $request)
 {
     $course = Course::findOrFail($request->input('course_id'));
     $this->authorize('view-course', $course);
     $question = new Question($request->only(['title', 'body']));
     $question->course()->associate($course);
     $question->user()->associate(auth()->user());
     $question->save();
     session()->flash('success', 'La pregunta ha sido enviada');
     return redirect()->back();
 }