backend/controllers/UserController.php
/**
     * Creates a new User model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new User model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new User model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new User();
        if ($model->load(Yii::$app->request->post()) ) {
            $model->username=Yii::$app->request->post()['User']['username'];
            $model->email=Yii::$app->request->post()['User']['email'];
            $model->level_user=Yii::$app->request->post()['User']['level_user'];
            if (!empty(Yii::$app->request->post()['User']['password_hash']))
            {
            $model->setPassword(Yii::$app->request->post()['User']['password_hash']);
            $model->generateAuthKey();
            }
            if ( $model->save()) {
                return $this->redirect(['index']);
            }
            $model->password_hash=Yii::$app->request->post()['User']['password_hash'];
             return $this->render('create', [
                'model' => $model,
            ]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
public function actionCreate ( ) { $ model = new User ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> username = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'username' ] ; $ model -> email = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'email' ] ; $ model -> level_user = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'level_user' ] ; if ( ! empty ( Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'password_hash' ] ) ) { $ model -> setPassword ( Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'password_hash' ] ) ; $ model -> generateAuthKey ( ) ; } if ( $ model -> save ( ) ) { return $ this -> redirect ( [ 'index' ] ) ; } $ model -> password_hash = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'password_hash' ] ; return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new User model.
Creates a new User model .