app/Http/Controllers/PostsController.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)
    {
        $rules = [
            'content' => 'required|max:1000'
        ];
        $validator = Validator::make($request->all(), $rules);
        if($validator->fails()){
            return response()->json($validator->errors(), 400);
        }
        $post = Post::find($id);
        $post->content = $request->content;
        $post->save();
        return response()->json($post, 200);
    }
public function update ( Request $ request , $ id ) { $ rules = [ 'content' => 'required|max:1000' ] ; $ validator = Validator :: make ( $ request -> all ( ) , $ rules ) ; if ( $ validator -> fails ( ) ) { return response ( ) -> json ( $ validator -> errors ( ) , 400 ) ; } $ post = Post :: find ( $ id ) ; $ post -> content = $ request -> content ; $ post -> save ( ) ; return response ( ) -> json ( $ post , 200 ) ; }
Update the specified resource in storage.
Update the specified resource in storage .