コード例 #1
0
ファイル: ManageController.php プロジェクト: samlx/Bulk
 /**
  * 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]);
     }
 }
コード例 #2
0
ファイル: Street.php プロジェクト: samlx/Bulk
 /**
  * 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');
 }
コード例 #3
0
ファイル: Estate.php プロジェクト: samlx/Bulk
 /**
  * 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;
 }