/**
  * Creates a new AuthAssignment model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new AuthAssignment();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'item_name' => $model->item_name, 'user_id' => $model->user_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionAddrole($id)
 {
     $model = new AuthAssignment();
     $model->user_id = $id;
     $command = Yii::$app->request->post('addroleAction');
     if (isset($command)) {
         $model->load(Yii::$app->request->post());
         $respond = $model->validate();
         if ($respond) {
             $auth = Yii::$app->authManager;
             $role = $auth->getRole($model->item_name);
             $auth->assign($role, $id);
             return $this->redirect(['view', 'id' => $id]);
         } else {
             if ($respond == FALSE) {
                 throw new HttpException(400, serialize($model->errors));
             }
         }
     } else {
         return $this->render('addrole', ['id' => $id, 'model' => $model]);
     }
 }