Пример #1
0
 /**
  * Lists all Info models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InfoSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->sort = ['defaultOrder' => ['published_at' => SORT_DESC]];
     $dataProvider->query->andFilterWhere(['{{info}}.locale' => Yii::$app->language]);
     if (Yii::$app->request->get('mid')) {
         $parentModel = Model::findOne(['id' => Yii::$app->request->get('mid')]);
         $models = Info::find()->andFilterWhere(['{{info}}.domain_id' => Yii::getAlias('@defaultDomainId'), '{{info}}.locale' => 'uk-UA'])->andWhere(['like', 'slug', $parentModel->slug])->all();
     } else {
         $models = Info::find()->andFilterWhere(['{{info}}.domain_id' => Yii::getAlias('@defaultDomainId'), '{{info}}.locale' => 'uk-UA'])->all();
     }
     $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title');
     $cars = Model::find()->andFilterWhere(['{{model}}.domain_id' => Yii::getAlias('@defaultDomainId'), '{{model}}.locale' => 'uk-UA'])->all();
     $carList = \yii\helpers\ArrayHelper::map($cars, 'id', 'title');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list, 'carList' => $carList]);
 }
Пример #2
0
 /**
  * Lists all Info models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InfoSearch();
     $searchModel->detachBehaviors();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // $dataProvider->sort = [
     //     'defaultOrder' => ['published_at' => SORT_DESC]
     // ];
     $dataProvider->sort->attributes['search_date_published'] = ['asc' => ['published_at' => SORT_ASC], 'desc' => ['published_at' => SORT_DESC]];
     $dataProvider->query->andFilterWhere(['info.locale' => Yii::$app->language]);
     //        $dataProvider->query->andFilterWhere(['!=', 'info.locale', 'en-US']);
     if (Yii::$app->request->get('mid')) {
         $parentModel = Model::findOne(['id' => Yii::$app->request->get('mid')]);
         $models = Info::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->andWhere(['like', 'slug', $parentModel->slug])->all();
     } else {
         $models = Info::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->all();
     }
     $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title');
     $cars = Model::find()->andFilterWhere(['domain_id' => Yii::$app->user->identity->domain_id, 'locale' => 'uk-UA'])->all();
     $carList = \yii\helpers\ArrayHelper::map($cars, 'id', 'title');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list, 'carList' => $carList]);
 }