Пример #1
0
 /**
  * Lists all Advert models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (Currency::find()->where(['>', 'date', time()])->orderBy(['date' => SORT_DESC])->asArray()->one() == null) {
         $currency = new Currency();
         if ($currency->exchangeRates()) {
             Yii::$app->session->setFlash('warning', 'Exchange rates might differ from actual ones');
         }
     }
     $disabled_subcat = 'disabled';
     $disabled_city = 'disabled';
     $searchModel = new AdvertSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $catList = ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name');
     $regionList = ArrayHelper::map(Region::find()->asArray()->all(), 'id', 'name');
     $subcatList = [];
     $cityList = [];
     if (Yii::$app->request->get('search') == 'search' && Yii::$app->request->get('AdvertSearch')['category_id'] !== '') {
         $subcatList = ArrayHelper::map(Subcategory::find()->where(['category_id' => Yii::$app->request->get('AdvertSearch')['category_id']])->asArray()->all(), 'id', 'name');
         $disabled_subcat = false;
     }
     if (Yii::$app->request->get('search') == 'search' && Yii::$app->request->get('AdvertSearch')['region_id'] !== '') {
         $cityList = ArrayHelper::map(City::find()->where(['region_id' => Yii::$app->request->get('AdvertSearch')['region_id']])->asArray()->all(), 'id', 'name');
         $disabled_city = false;
     }
     if (Yii::$app->request->get() == null || Yii::$app->request->get('period') == 'period') {
         $beforeValue = '';
         $afterValue = '';
     } else {
         $beforeValue = Yii::$app->request->get('before');
         $afterValue = Yii::$app->request->get('after');
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'catList' => $catList, 'subcatList' => $subcatList, 'regionList' => $regionList, 'cityList' => $cityList, 'beforeValue' => $beforeValue, 'afterValue' => $afterValue, 'disabled_subcat' => $disabled_subcat, 'disabled_city' => $disabled_city]);
 }
Пример #2
0
 /**
  * Lists all Advert models.
  * @return mixed
  */
 public function actionIndex()
 {
     $disabled_subcat = 'disabled';
     $disabled_city = 'disabled';
     $searchModel = new AdvertSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $catList = ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name');
     $regionList = ArrayHelper::map(Region::find()->asArray()->all(), 'id', 'name');
     $subcatList = [];
     $cityList = [];
     if (Yii::$app->request->get('search') == 'search' && Yii::$app->request->get('AdvertSearch')['category_id'] !== '') {
         $subcatList = ArrayHelper::map(Subcategory::find()->where(['category_id' => Yii::$app->request->get('AdvertSearch')['category_id']])->asArray()->all(), 'id', 'name');
         $disabled_subcat = false;
     }
     if (Yii::$app->request->get('search') == 'search' && Yii::$app->request->get('AdvertSearch')['region_id'] !== '') {
         $cityList = ArrayHelper::map(City::find()->where(['region_id' => Yii::$app->request->get('AdvertSearch')['region_id']])->asArray()->all(), 'id', 'name');
         $disabled_city = false;
     }
     if (Yii::$app->request->get() == null || Yii::$app->request->get('period') == 'period') {
         $beforeValue = '';
         $afterValue = '';
     } else {
         $beforeValue = Yii::$app->request->get('before');
         $afterValue = Yii::$app->request->get('after');
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'catList' => $catList, 'subcatList' => $subcatList, 'regionList' => $regionList, 'cityList' => $cityList, 'beforeValue' => $beforeValue, 'afterValue' => $afterValue, 'disabled_subcat' => $disabled_subcat, 'disabled_city' => $disabled_city]);
 }