public function renderJson() { if (!$this->model) { return Json::encode(['success' => 0, 'message' => \Yii::t('yincart', 'Error ID!'), 'errors' => []]); } else { if ($this->model->hasErrors()) { return Json::encode(['success' => 0, 'message' => \Yii::t('yincart', 'Save Error!'), 'errors' => $this->model->getErrors()]); } else { return Json::encode(['success' => 1, 'message' => \Yii::t('yincart', 'Save Success!'), 'id' => $this->model->getPrimaryKey()]); } } }
public function beforeSave($insert) { if (!$insert && $this->category_id != $this->getOldAttribute('category_id')) { $itemPropValueClass = Yincart::$container->itemPropValueClass; $itemPropValueClass::deleteAll(['item_id' => $this->item_id]); $skuClass = Yincart::$container->skuClass; $skuClass::deleteAll(['item_id' => $this->item_id]); } return parent::beforeSave($insert); }
public function behaviors() { return ArrayHelper::merge(parent::behaviors(), ['enum' => ['class' => EnumAttribute::className(), 'attributes' => ['type' => [1 => Yii::t('yincart', 'Text'), 2 => Yii::t('yincart', 'Select'), 3 => Yii::t('yincart', 'Checkbox')], 'is_key' => [0 => Yii::t('yincart', 'No'), 1 => Yii::t('yincart', 'Yes')], 'is_sale' => [0 => Yii::t('yincart', 'No'), 1 => Yii::t('yincart', 'Yes')], 'is_color' => [0 => Yii::t('yincart', 'No'), 1 => Yii::t('yincart', 'Yes')], 'is_search' => [0 => Yii::t('yincart', 'No'), 1 => Yii::t('yincart', 'Yes')], 'is_must' => [0 => Yii::t('yincart', 'No'), 1 => Yii::t('yincart', 'Yes')], 'status' => [0 => Yii::t('yincart', 'Disable'), 1 => Yii::t('yincart', 'Enable')]], 'changeOriginal' => $this->changeOriginal]]); }