app/Http/Controllers/ProductReviewsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\product_reviews  $product_reviews
     * @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, [
            "comment" => 'required'
        ]);
        $review = product_reviews::find($id);
        if($review->user_id != auth::user()->id){
            $response = [
                "status" => "error",
                "message" => "Unauthorized action"
            ];
            return response()->json($response, 401);
        }
        else
        {
            $review->comment = $request["comment"];
            $review->update();
            $response = [
                "message" => "Comment successfully updated",
                "data" => $review
            ];
            return response()->json($response, 201);
        }
    }
public function update ( Request $ request , $ id ) { $ this -> validate ( $ request , [ " comment " => 'required' ] ) ; $ review = product_reviews :: find ( $ id ) ; if ( $ review -> user_id != auth :: user ( ) -> id ) { $ response = [ " status " => " error " , " message " => " Unauthorized action " ] ; return response ( ) -> json ( $ response , 401 ) ; } else { $ review -> comment = $ request [ " comment " ] ; $ review -> update ( ) ; $ response = [ " message " => " Comment successfully updated " , " data " => $ review ] ; return response ( ) -> json ( $ response , 201 ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
//