/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CmsPages::find(); // add conditions that should always apply here $query->joinWith(['user']); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['page_id' => $this->page_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'username', $this->created_by])->andFilterWhere(['like', 'm_cms_pages.status', $this->status])->andFilterWhere(['like', 'menu_title', $this->menu_title]); return $dataProvider; }
/** * Get all active cms pages * @return CmsPages the retrieved model */ public function getAllCmsPages() { return CmsPages::find()->select(['page_id', 'menu_title'])->where(['status' => '1'])->asArray()->all(); }