typePublic()->joinWith('translation'); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => [ 'defaultOrder' => ['id' => SORT_DESC] ] ]); $this->load($params); if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $query->andFilterWhere([ 'id' => $this->id, 'category_id' => $this->category_id, ]); $query ->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; } public function categoriesList(): array { return ArrayHelper::map(BlogCategory::find()->orderBy('sort')->all(), 'id', function (BlogCategory $category) { return $category->translation->name; }); } public function statusList(): array { return BlogPostHelper::statusList(); } }