app/Http/Controllers/ProductReviewsController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\product_reviews  $product_reviews
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy($id)
    {
        $review = product_reviews::find($id);
        if($review->user_id != auth::user()->id)
        {
            return response()->json(["status" =>"error","message" => "Unauthorized action"], 401);
        }
        if ($review != null) {
            if ($review->delete()) {
                return response([
                    'status' => 'success',
                    'data'   => null,
                    'message' => 'Review deleted successfully'
                ]);
            } else {
                return response([
                    'status' => 'error',
                    'data' => null,
                    'code' => 500,
                    'message' => 'Update Failed!'
                ])->setStatusCode(500);
            }
        } else {
          return response([
                'status' => 'error',
                'data' => null,
                'code' => 404,
                'message' => 'Review with ID of ' . $id . 'Not found'
            ])->setStatusCode(404);
        }
    }
public function destroy ( $ id ) { $ review = product_reviews :: find ( $ id ) ; if ( $ review -> user_id != auth :: user ( ) -> id ) { return response ( ) -> json ( [ " status " => " error " , " message " => " Unauthorized action " ] , 401 ) ; } if ( $ review != null ) { if ( $ review -> delete ( ) ) { return response ( [ 'status' => 'success' , 'data' => null , 'message' => 'Review deleted successfully' ] ) ; } else { return response ( [ 'status' => 'error' , 'data' => null , 'code' => 500 , 'message' => 'Update Failed!' ] ) -> setStatusCode ( 500 ) ; } } else { return response ( [ 'status' => 'error' , 'data' => null , 'code' => 404 , 'message' => 'Review with ID of ' . $ id . 'Not found' ] ) -> setStatusCode ( 404 ) ; } }
Remove the specified resource from storage.
Remove the specified resource from storage .