public function actionUserEducation()
 {
     if (Yii::$app->request->isPost) {
         $infoParams = Yii::$app->request->post();
         $infoParams['UsersEducation']['user_id'] = Yii::$app->user->id;
         if (empty($infoParams['UsersEducation']['end_time'])) {
             $infoParams['UsersEducation']['end_time'] = date('Y-m-d H:i:s', time());
         }
         $infoInfo = $infoParams;
         $model = new UsersEducation();
         if ($model->load($infoInfo) && $model->save()) {
             return $this->redirect('/user-center/user-info');
         } else {
             throw new ServerErrorHttpException('系统错误,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE));
         }
     } else {
         if (Yii::$app->request->get('id')) {
             UsersEducation::findOne(Yii::$app->request->get('id'))->delete();
             return $this->redirect('/user-center/user-info');
         } else {
             $model = UsersEducation::findAll(['user_id' => Yii::$app->user->id]);
             $levelName = Level::getOneLevelNameById(Yii::$app->user->identity->level_id);
             $photo = UsersInfo::getPhotoByUserId(\Yii::$app->user->id);
             $messageCount = MessagesUsers::getCountByUserIdAndType(\Yii::$app->user->id);
             $currentTrain = TrainUsers::getTrainByUserId(Yii::$app->user->id);
             $data = ['levelName' => $levelName, 'currentTrain' => $currentTrain, 'photo' => $photo, 'messageCount' => $messageCount];
             return $this->render('user-education', ['data' => $data, 'model' => $model]);
         }
     }
 }
 /**
  * Finds the UsersEducation model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UsersEducation the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UsersEducation::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }