/**
  * @return \yii\db\ActiveQuery
  */
 public function getRank()
 {
     return $this->hasOne(YBoardRank::className(), ['id' => 'rank_id']);
 }
 /**
  * handle Ajax call for saving ranks
  */
 public function actionSaveRank()
 {
     if (!Yii::$app->user->can('app.forum.setting.save-rank')) {
         throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
     }
     $json = [];
     $model = new YBoardRank();
     if (isset($_POST[$model->formName()])) {
         if ($_POST[$model->formName()]['id'] != '') {
             $model = YBoardRank::findOne($_POST[$model->formName()]['id']);
             //remove from the POST
             unset($_POST[$model->formName()]['id']);
         }
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             $json['success'] = 'yes';
         } else {
             $json['error'] = YBoard::t('yboard', 'Could not save Rank');
         }
     }
     echo json_encode($json);
     Yii::$app->end();
 }