Beispiel #1
0
 /**
  * 角色关联用户
  */
 public function actionRelateUser()
 {
     $roleId = Yii::$app->request->getQueryParam('id');
     if (!preg_match('/^\\d+$/', $roleId)) {
         throw new Exception('角色ID不合法');
     }
     $roleModel = $this->findModel($roleId);
     $model = new User();
     $dataProvider = $model->search(Yii::$app->request->queryParams);
     $updateParams = Yii::$app->request->post('selection');
     if ($updateParams) {
         $userIds = $updateParams;
         if ($roleModel->updateRelateUser($userIds, $roleId, $model)) {
             return $this->redirect(['/rbac/role/relate-user', 'id' => $roleModel->role_id]);
         }
     }
     return $this->render('/rbac/role/relateUser', ['model' => $model, 'dataProvider' => $dataProvider, 'roleModel' => $roleModel]);
 }