public function updateSetting($name, $registration, $website, $logo, $copyright, $email, $background, $phone, $addr)
 {
     $model = WebSiteConfig::find()->one();
     if (!$model) {
         $model = new WebSiteConfig();
     }
     $model->name = $name;
     $model->registration = $registration;
     $model->website = $website;
     $model->logo = $logo;
     $model->copyright = $copyright;
     $model->email = $email;
     $model->background = $background;
     $model->phone = $phone;
     $model->addr = $addr;
     $model->addTime = date('Y-m-d H:i:s', time());
     $model->addUser = \Yii::$app->session->get(Variable::$session_userId_str);
     if ($model->save()) {
         return true;
     }
     return false;
 }
 public function actionIndex()
 {
     //        error_reporting(0);
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $form = new SettingForm();
     $model = new WebSiteConfig();
     $settingModel = WebSiteConfig::find()->one();
     $req = Yii::$app->request;
     //创建一个请求对象
     //修改
     if ($form->load($req->post()) && $form->validate()) {
         //            echo '--';
         //            print_r($form);
         //            echo '--';
         //            exit;
         if ($model->updateSetting($form->name, $form->registration, $form->website, $form->logo, $form->copyright, $form->email, $form->background, $form->phone, $form->addr)) {
             Yii::$app->session->setFlash('success', '配置成功');
             $this->redirect(Variable::$setting_url);
             return;
         }
         Yii::$app->session->setFlash('error', '配置更新失败,请刷新重试');
     }
     $form->email = $settingModel->email;
     $form->name = $settingModel->name;
     $form->registration = $settingModel->registration;
     $form->website = $settingModel->website;
     $form->logo = $settingModel->logo;
     $form->copyright = $settingModel->copyright;
     $form->background = $settingModel->background;
     $form->phone = $settingModel->phone;
     $form->addr = $settingModel->addr;
     //        print_r($settingModel);
     return $this->render(Variable::$setting_view, ['model' => $form]);
 }