Beispiel #1
0
 public function actionCityList()
 {
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         $city_list = ArrayHelper::getColumn(GeobaseCity::find()->where(['like', 'name', Yii::$app->request->get('q')])->all(), 'name');
         return $city_list;
     }
 }
Beispiel #2
0
 public function actionMngAd($id = null)
 {
     if (!$id) {
         $model = new TorAds();
         $model->geobase_city = User::findOne(Yii::$app->user->id)->geobase_city_id ? GeobaseCity::findOne(User::findOne(Yii::$app->user->id)->geobase_city_id)->name : null;
     } else {
         $model = TorAds::findOne($id);
         $model->geobase_city = GeobaseCity::findOne($model->city_id)->name;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', 'Объявление добавлено');
         return $this->redirect('/tor/my-ads');
     }
     return $this->render('/tor/mngAd', ['model' => $model]);
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCity()
 {
     return $this->hasOne(GeobaseCity::className(), ['id' => 'city_id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGeobaseCity()
 {
     return $this->hasOne(GeobaseCity::className(), ['id' => 'geobase_city_id'])->orderBy(['name' => SORT_ASC]);
 }