Пример #1
0
 /**
  * 删除角色
  */
 public function actionDeleteRole($name)
 {
     $mRule = AuthRule::findOne(['name' => $name]);
     $model = AuthItem::findOne(['name' => $name]);
     //参数过滤
     if (!$model || !$mRule) {
         Yii::$app->session->setFlash('error', '参数错误!');
     }
     if ($mRule->delete() && $model->delete()) {
         Yii::$app->session->setFlash('success', '角色-' . $name . '删除成功');
     }
     return $this->redirect('role');
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRuleName()
 {
     return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']);
 }