/** * Lists all Goods models. * @return mixed */ public function actionIndex() { $searchModel = new GodosSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $cates = Category::find()->all(); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cates' => $cates]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'pid' => $this->pid, 'level' => $this->level, 'cover' => $this->cover, 'sort' => $this->sort, 'is_leaf' => $this->is_leaf, 'created_at' => $this->created_at, 'status' => $this->status]); $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description]); return $dataProvider; }