/** * Update current Estate model * * @param int $id * @return string|\yii\web\Response * @throws ForbiddenHttpException * @throws NotFoundHttpException */ public function actionUpdate($id) { $model = $this->findEstate($id); $streets = Street::getStreetsArrayByCityId(City::DEFAULT_CITY); if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->save()) { Yii::$app->session->setFlash('success', Yii::t('app', 'FLASH_ESTATE_UPDATED')); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'streets' => $streets]); } }
/** * Function returns structured array for DropDown input * * @param int $city_id City id * @return array */ public static function getStreetsArrayByCityId($city_id) { return ArrayHelper::map(Street::getStreetsByCity($city_id), 'id', 'title'); }
/** * Get the title of Street where Estate is placed * * @return string */ public function getStreetName() { /** @var Street $model */ $model = Street::findOne(['id' => $this->getStreetId()]); return $model->title; }