/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['key' => 'id', 'query' => $query, 'pagination' => ['pageSize' => 100]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'dateCreate' => $this->dateCreate, 'visible' => $this->visible, 'parentId' => $this->parentId]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'metaKeywords', $this->metaKeywords])->andFilterWhere(['like', 'metaDescription', $this->metaDescription]); return $dataProvider; }
public function run() { $items = Category::find()->where(['parentId' => 0])->all(); return $this->render('nav', ['items' => $items]); }