/**
  * create a default category for reservation
  * @return array
  * @param $name, string
  * @param $propertyName, string
  */
 public function createDefaultReservationCategory($name, $propertyName = 'price')
 {
     $condition = ['name' => $name, 'accountId' => $this->accountId];
     $category = ModelProductCategory::findOne($condition);
     if (empty($category)) {
         $category = new ModelProductCategory();
         $data = ['name' => $name, 'accountId' => $this->accountId, 'properties' => [['name' => $propertyName, 'type' => 'input', 'defaultValue' => '', 'isRequired' => 'true', 'order' => 1, 'propertyId' => 'wm' . $propertyName, 'id' => StringUtil::uuid()]]];
         $category->load($data, '');
         $category->save();
     }
     return $category;
 }
 public function actionCreate()
 {
     $params = $this->getParams();
     $accountId = $this->getAccountId();
     if (ProductCategory::RESERVATION_CATEGORY_NAME == $params['name']) {
         throw new InvalidParameterException(Yii::t('product', 'categoryName_isUsed'));
     }
     $result = CategoryProperty::checkUniqueName('category', $params['name'], '', $accountId, '');
     if (false === $result) {
         throw new InvalidParameterException(['categoryName' => Yii::t("product", "categoryName_isUsed")]);
     }
     $productcategory = new ProductCategory();
     $params['accountId'] = $accountId;
     $productcategory->load($params, '');
     if ($productcategory->save()) {
         return $productcategory;
     }
     throw new ServerErrorHttpException('Failed to create the category.');
 }