app/Http/Controllers/PostController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $this->validate($request,array(     
            'title'=>'required|max:255',
            'body'=>'required'
                ));
        $post=Post::find($id);               
        $post->title=$request->input('title');  
        $post->body=$request->input('body'); 
        $post->save();                            
        return redirect()->route('posts.show',$post->id); 
    }
public function update ( Request $ request , $ id ) { $ this -> validate ( $ request , array ( 'title' => 'required|max:255' , 'body' => 'required' ) ) ; $ post = Post :: find ( $ id ) ; $ post -> title = $ request -> input ( 'title' ) ; $ post -> body = $ request -> input ( 'body' ) ; $ post -> save ( ) ; return redirect ( ) -> route ( 'posts.show' , $ post -> id ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//validate the data first //grab the data from existing record //grab the data from existing record //grab the data from existing record //commite the change and save to database //redirected changes to show;