app/Http/Controllers/CommentController.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(Request $request)
    {
        $request->validate([
            'name' => 'required',
            'content' => 'required',
        ]);
        $data = $request->all();
        $newComment = New Comment();
        $newComment->fill($data);
        $saved = $newComment->save();
        if ($saved) {
            return redirect(url()->previous());
        }
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => 'required' , 'content' => 'required' , ] ) ; $ data = $ request -> all ( ) ; $ newComment = New Comment ( ) ; $ newComment -> fill ( $ data ) ; $ saved = $ newComment -> save ( ) ; if ( $ saved ) { return redirect ( url ( ) -> previous ( ) ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .