From 31df7de9e00e39dbea5dbd2553860aacf687db30 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Tue, 5 Sep 2023 15:33:37 +0200 Subject: [PATCH] fix: updating wish --- src/api/wishes.php | 10 +++++----- src/classes/wishthis/Wish.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/api/wishes.php b/src/api/wishes.php index c814733c..33706385 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -110,7 +110,7 @@ switch ($_SERVER['REQUEST_METHOD']) { if (isset($_POST['wish_id'], $_POST['wishlist_id'])) { /** Update wish */ - $wish = new Wish($_POST['wish_id']); + $wish = Wish::getFromId($_POST['wish_id']); /** Update wish information */ if (!empty($wish_url)) { @@ -160,14 +160,14 @@ switch ($_SERVER['REQUEST_METHOD']) { `is_purchasable` = :wish_is_purchasable WHERE `id` = :wish_id', array( - 'wishlist_id' => $wish->wishlist, + 'wishlist_id' => $wish->getWishlistId(), 'wish_title' => $wish_title, 'wish_description' => $wish_description, 'wish_image' => $wish_image, 'wish_url' => $wish_url, 'wish_priority' => $wish_priority, 'wish_is_purchasable' => $wish_is_purchasable, - 'wish_id' => $wish->id, + 'wish_id' => $wish->getId(), ) ); @@ -189,12 +189,12 @@ switch ($_SERVER['REQUEST_METHOD']) { :wish_price );', array( - 'wish_id' => $wish->id, + 'wish_id' => $wish->getId(), 'wish_price' => $wish_price, ) ); - $response['lastInsertId'] = $wish->id; + $response['lastInsertId'] = $wish->getId(); } elseif (isset($_POST['wishlist_id'])) { /** Insert wish */ $wishlist_id = $_POST['wishlist_id']; diff --git a/src/classes/wishthis/Wish.php b/src/classes/wishthis/Wish.php index 831bcad4..5bd852bb 100644 --- a/src/classes/wishthis/Wish.php +++ b/src/classes/wishthis/Wish.php @@ -407,4 +407,14 @@ class Wish return $wishArray; } + + public function getId(): int + { + return $this->id; + } + + public function getWishlistId(): int + { + return $this->wishlist; + } }