/** * Finds the Estate model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * If the model is not accessible, a 403 HTTP exception will be thrown. * * @param int $id * @return Estate * @throws ForbiddenHttpException * @throws NotFoundHttpException */ protected function findEstate($id) { /** @var Estate $model */ $model = Estate::findOne($id); if (is_null($model)) { throw new NotFoundHttpException(Yii::t('app', 'ERROR_WRONG_ID')); } if (!$model->isAccessibleForCurrentUser()) { throw new ForbiddenHttpException(Yii::t('app', 'ERROR_FORBIDDEN')); } return $model; }
/** * Getter current Estate * * @return Estate */ public function getEstate() { return Estate::findOne($this->estate_id); }