public function actionUpdate($id) { $params = $this->getParams(); $accountId = $this->getAccountId(); if (!empty($params['order'])) { //update the order $where = ['_id' => new MongoId($id), 'accountId' => $accountId]; $productcategory = ProductCategory::findOne($where); $productcategory = CategoryProperty::updatePropertyOrder($productcategory, $params); //return the category id and property $data['id'] = $id; $data['properties'] = CategoryProperty::showOrderPeoperty($productcategory->properties); return $data; } else { //update the property not include order if (!isset($params['propertyId'])) { throw new BadRequestHttpException("propertyId params missing"); } self::checkReversationProperty($id, $params['propertyId'], $accountId); $categoryId = new MongoId($id); $result = CategoryProperty::checkUniqueName('property', $params['name'], $categoryId, $accountId, $params['propertyId']); if (false === $result) { throw new InvalidParameterException(['categoryPropertyName' => Yii::t("product", "propertyName_isUsed")]); } $productcategory = CategoryProperty::updateProperty($id, $params, $accountId); foreach ($productcategory->properties as $key => $properties) { if ($properties['id'] == $params['propertyId']) { return $properties; } } } }