/**
  * Creates a new AuthItemChild model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new AuthItemChild();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'parent' => $model->parent, 'child' => $model->child]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionAddchild($idparent)
 {
     $model = new AuthItemChild();
     $model->parent = $idparent;
     $command = Yii::$app->request->post('commandAction');
     if (isset($command)) {
         $model->load(Yii::$app->request->post());
         $respond = $model->validate();
         if ($respond) {
             $auth = Yii::$app->authManager;
             $parent = $auth->getRole($model->parent);
             if (is_null($parent)) {
                 $parent = $auth->getPermission($model->parent);
             }
             $child = $auth->getRole($model->child);
             if (is_null($child)) {
                 $child = $auth->getPermission($model->child);
             }
             $auth->addChild($parent, $child);
             return $this->redirect(['view', 'id' => $idparent]);
         } else {
             throw new HttpException('400', serialize($model->errors));
         }
     } else {
         return $this->render('addchild', ['model' => $model]);
     }
 }