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)
    {
        $validated = $request->validate([
            'title' => 'required|unique:posts|max:255',
            'body' => 'required',
        ]);
        $post = new Post;
        $post->title = $request->title;
        $post->body = $request->body;
        $post->save();
        return redirect()->route('home');
    }
public function store ( Request $ request ) { $ validated = $ request -> validate ( [ 'title' => 'required|unique:posts|max:255' , 'body' => 'required' , ] ) ; $ post = new Post ; $ post -> title = $ request -> title ; $ post -> body = $ request -> body ; $ post -> save ( ) ; return redirect ( ) -> route ( 'home' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
/*$this->validate($request, [
            'email' => 'required|email',
            'password' => 'required'|confirmed,
        ]);*/ //return redirect('/home');