public function actionAdminUser() { $model = new AdminUser(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if (InstallerHelper::createAdminUser($model, $this->db())) { Yii::$app->session->setFlash('info', Yii::t('app', 'Admin user created')); return $this->redirect(['final']); } } return $this->render('admin-user', ['model' => $model]); }
private function adminUser() { $model = new AdminUser(); foreach ($model->attributes() as $attribute) { $model->setAttributes([$attribute => $this->prompt("-> {$attribute}", ['required' => true, 'default' => $model->{$attribute}])]); } if (!$this->interactive) { $model->password = '******'; } if ($model->validate()) { InstallerHelper::createAdminUser($model, $this->db()); return $this->finalStep(); } else { $this->stderr("Error in input data: " . var_export($model->errors, true), Console::FG_RED); return $this->adminUser(); } }