示例#1
0
 public function afterDelete()
 {
     parent::afterDelete();
     if ($model = $this->getErrorQuery()) {
         $model->delete();
     }
 }
 public function getMenu()
 {
     $moduleName = AbstractModel::moduleName(static::className());
     $model = $this->findModel();
     $uniqueKey = 0;
     $items = $model::find()->orderBy(['lft' => SORT_ASC])->asArray()->all();
     foreach ($items as &$item) {
         $uniqueKey++;
         $nodeId = $uniqueKey . '-id-' . $item['id'];
         $item['nodeAttributes'] = ['id' => $nodeId, 'text' => $item['name'], 'type' => 'folder', 'active' => \Yii::$app->request->get('id') == $item['id'], 'a_attr' => ['data-id' => $nodeId, 'href' => ["/{$moduleName}/category/update", 'id' => $item['id']]]];
     }
     $treeWidget = new ARTreeMenuWidget(['items' => $items, 'view' => 'nested']);
     return $treeWidget->run();
 }
示例#3
0
 /**
  * @inheritdoc
  */
 public function beforeSave($insert)
 {
     if (!parent::beforeSave($insert)) {
         return false;
     }
     if ($insert && !$this->api_key) {
         $this->generateApiKey();
     }
     if ($insert && !$this->auth_key) {
         $this->generateAuthKey();
     }
     if ($insert || $this->isAttributeChanged('password')) {
         $this->password = $this->generatePassword($this['password']);
     }
     return true;
 }
示例#4
0
 /**
  * Relative path for saving model files.
  * @return string path.
  */
 public function getStoragePath()
 {
     $moduleName = AbstractModel::moduleName(static::className());
     $owner_id = $this->getAttribute('owner_id') ?: Yii::$app->user->id;
     return "@app/web/files/{$owner_id}/{$moduleName}/" . $this->formName() . '/' . $this->id;
 }
示例#5
0
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (!$this->pid) {
         throw new Exception("Can not delete the root page");
     }
     return parent::beforeDelete();
 }
 /**
  * Relative path for saving model files.
  * @return string path.
  */
 public function getStoragePath()
 {
     $moduleName = AbstractModel::moduleName(static::className());
     return "@app/web/files/{$moduleName}/" . $this->formName() . '/' . $this->id;
 }