/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CmsShow::find(); $query->orderBy(['created_at' => SORT_DESC]); $dataProvider = new ActiveDataProvider(['query' => $query]); if ($this->load($params) && !$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'catalog_id' => $this->catalog_id, 'click' => $this->click, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'brief', $this->brief])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'template_show', $this->template_show])->andFilterWhere(['like', 'author', $this->author]); return $dataProvider; }
public function actionList($id) { if (!$id) { $this->goHome(); } //$this->layout = 'column2'; $list = CmsCatalog::findOne($id); $ids = CmsCatalog::getArraySubCatalogId($id, CmsCatalog::find()->asArray()->all()); $query = CmsShow::find(); $query->where(['status' => Status::STATUS_ACTIVE, 'catalog_id' => $ids]); $pagination = new Pagination(['defaultPageSize' => isset(Yii::$app->params['cmsListPageCount']) ? Yii::$app->params['cmsListPageCount'] : 2, 'totalCount' => $query->count()]); $shows = $query->orderBy(['created_at' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render($list->template_list, ['list' => $list, 'shows' => $shows, 'pagination' => $pagination, 'catalogId' => $id]); }