public function actionSignUp() { $model = new \app\models\User(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect('/personal'); } return $this->render('sign-up', ['model' => $model]); }
/** * Ruturn user-setup page if application no-user found. * @return mixed */ public function actionUserSetup() { $chkUserTbl = \app\models\User::find()->exists(); if ($chkUserTbl) { return $this->redirect(['setup-completed']); } $model = new \app\models\User(); $model->scenario = 'firstTime'; $chkUserTbl = \app\models\User::find()->exists(); if ($chkUserTbl) { return $this->redirect(['site/login']); } if ($model->load(Yii::$app->request->post())) { $model->created_by = 1; $model->created_at = new \yii\db\Expression('NOW()'); $model->user_login_id = $model->admin_user; $model->user_password = MD5($model->create_password . $model->create_password); $model->user_type = 'A'; if ($model->save()) { $auth_assign = new \app\models\AuthAssignment(); $auth_assign->item_name = 'SuperAdmin'; $auth_assign->user_id = $model->user_id; $auth_assign->created_at = date_format(date_create(), 'U'); if ($auth_assign->save(false)) { return $this->redirect(['setup-completed']); } } } return $this->render('user-setup', ['model' => $model]); }