Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\AnswerRequest $request)
 {
     $Answer = new \App\Answer();
     $Answer->answer = $request->get('answer');
     $Answer->user_id = \Auth::user()->id;
     $Answer->question_id = $request->get('question_id');
     $Answer->save();
     \Session::flash('flash_message', 'Your Answer has been Posted !!!');
     return redirect()->back();
 }
Ejemplo n.º 2
0
 public function update(AnswerRequest $request, int $id)
 {
     $answer = Answer::findOrFail($id);
     $this->authorize('edit-answer', $answer);
     $answer->body = $request->get('body');
     $answer->save();
     session()->flash('success', 'La respuesta ha sido editada.');
     return redirect()->route('question.show', $answer->question->id);
 }