app/Http/Controllers/PostsController.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([
            'title' => 'required',
            'body' => 'required'
       ]);
       Posts::create($request->all());
       return redirect()->route('posts.index');
       }
public function store ( Request $ request ) { $ request -> validate ( [ 'title' => 'required' , 'body' => 'required' ] ) ; Posts :: create ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'posts.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .