fix: updating wish

This commit is contained in:
grandeljay 2023-09-05 15:33:37 +02:00
parent b19c3221a9
commit 31df7de9e0
2 changed files with 15 additions and 5 deletions

View file

@ -110,7 +110,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
if (isset($_POST['wish_id'], $_POST['wishlist_id'])) { if (isset($_POST['wish_id'], $_POST['wishlist_id'])) {
/** Update wish */ /** Update wish */
$wish = new Wish($_POST['wish_id']); $wish = Wish::getFromId($_POST['wish_id']);
/** Update wish information */ /** Update wish information */
if (!empty($wish_url)) { if (!empty($wish_url)) {
@ -160,14 +160,14 @@ switch ($_SERVER['REQUEST_METHOD']) {
`is_purchasable` = :wish_is_purchasable `is_purchasable` = :wish_is_purchasable
WHERE `id` = :wish_id', WHERE `id` = :wish_id',
array( array(
'wishlist_id' => $wish->wishlist, 'wishlist_id' => $wish->getWishlistId(),
'wish_title' => $wish_title, 'wish_title' => $wish_title,
'wish_description' => $wish_description, 'wish_description' => $wish_description,
'wish_image' => $wish_image, 'wish_image' => $wish_image,
'wish_url' => $wish_url, 'wish_url' => $wish_url,
'wish_priority' => $wish_priority, 'wish_priority' => $wish_priority,
'wish_is_purchasable' => $wish_is_purchasable, 'wish_is_purchasable' => $wish_is_purchasable,
'wish_id' => $wish->id, 'wish_id' => $wish->getId(),
) )
); );
@ -189,12 +189,12 @@ switch ($_SERVER['REQUEST_METHOD']) {
:wish_price :wish_price
);', );',
array( array(
'wish_id' => $wish->id, 'wish_id' => $wish->getId(),
'wish_price' => $wish_price, 'wish_price' => $wish_price,
) )
); );
$response['lastInsertId'] = $wish->id; $response['lastInsertId'] = $wish->getId();
} elseif (isset($_POST['wishlist_id'])) { } elseif (isset($_POST['wishlist_id'])) {
/** Insert wish */ /** Insert wish */
$wishlist_id = $_POST['wishlist_id']; $wishlist_id = $_POST['wishlist_id'];

View file

@ -407,4 +407,14 @@ class Wish
return $wishArray; return $wishArray;
} }
public function getId(): int
{
return $this->id;
}
public function getWishlistId(): int
{
return $this->wishlist;
}
} }