public function actionSetAdmin()
 {
     $model = new AdminForm();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && $model->save() && $this->install($model)) {
             return $this->renderJsonMessage(true);
         } else {
             return $this->renderJsonMessage(false, $model->formatErrors());
         }
     }
     return $this->render('setadmin', ["model" => $model]);
 }
Exemplo n.º 2
0
 public function actionSetAdmin()
 {
     $model = new AdminForm();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post())) {
         if (!$model->validate() || !$model->save()) {
             return $this->renderJsonMessage(false, $model->formatErrors());
         }
         $error = $this->installDb();
         if ($error != null) {
             return $this->renderJsonMessage(false, $error);
         }
         $this->installConfig();
         // 创建用户
         $error = $this->createAdminUser();
         if ($error != null) {
             return $this->renderJsonMessage(false, $error);
         }
         \Yii::$app->getCache()->flush();
         //安装完成
         Module::getInstance()->setInstalled();
         return $this->renderJsonMessage(true);
     }
     return $this->render('setadmin', ["model" => $model]);
 }