app/Http/Controllers/AnswerController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Question $question, Request $request)
    {
        $question->answers()->create($request->validate([
            'body' => 'required'
        ])+ ['user_id'=> \Auth::id()]);
        return back()->with('success','Answers Submitted');
    }
public function store ( Question $ question , Request $ request ) { $ question -> answers ( ) -> create ( $ request -> validate ( [ 'body' => 'required' ] ) + [ 'user_id' => \ Auth :: id ( ) ] ) ; return back ( ) -> with ( 'success' , 'Answers Submitted' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .