public function removeDiscountOnCategory($categoryId) { $condition = 'category_id = ' . $categoryId; $categoryPromotion = $this->db->getAllEntitiesWithCondition(self::PROMO_CATEGORIES_TABLENAME, $condition, 'promotedAt'); $discount = $categoryPromotion[0]['discount']; $productsInCategory = $this->db->getAllEntitiesWithCondition(self::PRODUCTS_TABLENAME, "category_id={$categoryId}", 'id'); foreach ($productsInCategory as $product) { $restoredPrice = $product['price'] + $product['price'] * ($discount / 100); $isUpdated = $this->db->updateEntityById(self::PRODUCTS_TABLENAME, array("price" => $restoredPrice), $product['id']); } if ($isUpdated) { $remove = $this->db->deleteEntityById(self::PROMO_CATEGORIES_TABLENAME, $categoryPromotion[0]['id']); } return $remove; }
public function changePassword($userId, $newPassword) { $isChanged = $this->db->updateEntityById(self::USERS_TABLENAME, array("password" => password_hash($newPassword, AppConfig::PASSWORD_CRYPT_METHOD)), $userId); return $isChanged; }
public function remove($id) { $isDeleted = $this->db->updateEntityById(self::PRODUCTS_TABLENAME, array("is_sold" => 1), $id); return $isDeleted; }