app/Http/Controllers/PostController.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)
    {
        $this->validate($request,array(
            'title'=>'required|max:255',
            'body'=>'required'
                ));
        $post=new Post;
        $post->title=$request->title;
        $post->body=$request->body;
        $post->save();
        Session::flash('success','Your blog post successfully posted!!');
        return redirect()->route('posts.show',$post->id);
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , array ( 'title' => 'required|max:255' , 'body' => 'required' ) ) ; $ post = new Post ; $ post -> title = $ request -> title ; $ post -> body = $ request -> body ; $ post -> save ( ) ; Session :: flash ( 'success' , 'Your blog post successfully posted!!' ) ; return redirect ( ) -> route ( 'posts.show' , $ post -> id ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//validate the data //store to database //redirected to another page