/** * Creates a new AuthItem model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new AuthItem(null); $model->type = Item::TYPE_PERMISSION; if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) { MenuHelper::invalidate(); return $this->redirect(['view', 'id' => $model->name]); } else { return $this->render('create', ['model' => $model]); } }
/** * @return \yii\db\ActiveQuery */ public function getAuthItems() { return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']); }
/** * @return \yii\db\ActiveQuery */ public function getItemName() { return $this->hasOne(AuthItem::className(), ['name' => 'item_name']); }
/** * @return \yii\db\ActiveQuery */ public function getParents() { return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable('{{%auth_item_child}}', ['child' => 'name']); }