public function actionList() { //$query = Article::find();$articles = Article::findAll(["status" => 1]); $query = Article::find()->with('comments'); $dataProvider = new ActiveDataProvider(['query' => $query]); return $this->render("list", ["dataProvider" => $dataProvider]); }
public function actionIndex() { //处理本页面按钮操作 $request = Yii::$app->request; if ($op = $request->get('op')) { //pubilsh article or not publish article $id = $request->get('id'); $video = Article::find()->where(['id' => $id])->one(); if ($op == 'p') { if ($video->status == 0) { $video->status = 1; } else { $video->status = 0; } $video->publish_time = date("Y-m-d H:i:s", time()); } //delete article if ($op == 'd') { $video->status = -1; } $video->save(false); } //设置 where 语句 $where = 'type = 2 and status != -1'; $query = Article::find()->where($where); //使用分页组件 $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]); //拿到视频列表 $videos = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('index', ['articles' => $videos, 'pagination' => $pagination, 'page' => Yii::$app->request->get('page')]); }
public function actionView($id) { $this->view_data['article'] = $article = Article::find()->where("id = {$id}")->asArray()->one(); //获取这篇文章的所有留言 $this->view_data['comments'] = Article::getComments($article['id']); return $this->render('view', $this->view_data); }
public function actionArticlelist() { //分页读取类别数据 $model = Article::find()->with('cate'); $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $model->count()]); $model = $model->orderBy('id ASC')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('artlist', ['model' => $model, 'pagination' => $pagination]); }
/** * Updates an existing Article model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model, 'categories' => ArticleCategory::find()->active()->all(), 'ads' => Ad::find()->all(), 'articles' => Article::find()->all()]); } }
/** * @param $slug * @return string * @throws NotFoundHttpException */ public function actionView($slug) { $model = Article::find()->published()->andWhere(['slug' => $slug])->one(); if (!$model) { throw new NotFoundHttpException(); } $viewFile = $model->view ?: 'view'; return $this->render($viewFile, ['model' => $model]); }
/** * Deletes an existing ArticleCategory model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $articleModel = Article::find()->andWhere(['category_id' => $id])->one(); if (null === $articleModel) { $this->findModel($id)->delete(); } else { Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for article #' . $articleModel->id . ' before delete.'), 'options' => ['class' => 'alert-error']]); } return $this->redirect(['index']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Article::find()->orderBy('created_at DESC'); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'author', $this->author]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Article::find()->published(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'category_id' => $this->category_id]); $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
public static function getMetaTags() { $tags = []; $locale = null; $arr = self::parseUrl(Yii::$app->request->pathInfo); if (!empty($arr[0]) and !empty($arr[1]) and !empty($arr[2]) and !empty($arr[3])) { $shortLocale = $arr[0]; $controller = $arr[1]; $action = $arr[2]; $slug = $arr[3]; foreach (Yii::$app->params['availableLocales'] as $k => $v) { if ($shortLocale == explode('-', $k)[0]) { $locale = $k; } } switch ($controller) { case 'page': $model = self::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'article': $model = Article::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'promo': //$model = Promo::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'project': $model = Project::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; } //hardcore :) json to array if (!empty($model) and !empty($model->head)) { $arr = json_decode($model->head, true); foreach ($arr as $key => $value) { foreach ($value as $key2 => $value2) { //custom meta tag if (4 == count($value2)) { $value2 = array_values($value2); $value2 = [$value2[0] => $value2[1], $value2[2] => $value2[3]]; } $tags[] = $value2; } } } if (empty($model)) { throw new NotFoundHttpException('The requested page does not exist.'); } if (!empty($tags[0]) and !empty($tags[0]['name']) and 'title' == !empty($tags[0]['name']) and !empty($tags[0]['content'])) { Yii::$app->view->title = $tags[0]['content']; } else { Yii::$app->view->title = $model->title; } } return $tags; }
/** * Lists the Article models in a specific category $slug. * * @param $slug * @return mixed */ public function actionTag($slug) { $model = Tag::find()->andWhere(['slug' => $slug])->one(); if (!$model) { throw new NotFoundHttpException(Yii::t('frontend', 'Page not found.')); } $query = Article::find()->with('category')->joinWith('tags')->where('{{%tag}}.slug = :slug', [':slug' => $slug])->published(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10]]); $dataProvider->sort = ['defaultOrder' => ['created_at' => SORT_DESC]]; return $this->render('tag', ['model' => $model, 'dataProvider' => $dataProvider, 'menuItems' => self::getMenuItems()]); }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Article::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body]); return $dataProvider; }
public function actionIndex() { if (\Yii::$app->user->isGuest) { $this->redirect(['user/sign-in/login']); } $article = (new Query())->from('article')->all(); $query = Article::find(); $provide = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC, 'title' => 'simon']]]); $provide->prepare(); $pagination = $provide->getPagination(); return $this->render('index', ['article' => $provide->getModels(), 'pageCount' => $pagination->pageCount, 'page' => $pagination->page, 'links' => $pagination->getLinks()]); }
public function actionSearchList($q = null) { $out = []; if ($q) { $query = Article::find()->where(['LIKE', 'title', $q])->orWhere(['LIKE', 'body', $q]); $data = $query->limit(10)->all(); } foreach ($data as $d) { $out[] = ['value' => $d['title']]; } echo Json::encode($out); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Article::find()->where(['in', 'status', [Article::STATUS_GATHER, Article::STATUS_DISPLAY]]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100]]); $this->load($params); if (!$this->validate()) { return $dataProvider; } if ($this->status) { $query->andFilterWhere(['like', 'status', $this->status]); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Article::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ArticleModel::find()->orderBy('id desc'); $dataProvider = new ActiveDataProvider(['query' => $query]); $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; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'status' => $this->status]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'cover', $this->cover]); return $dataProvider; }
/** * @param string $category * @param string $slug * @return string * @throws NotFoundHttpException */ public function actionView($category, $slug) { $model = Article::find()->published()->andWhere(['slug' => $slug])->one(); if (!$model) { throw new NotFoundHttpException(); } //Мета-теги foreach (['description', 'keywords'] as $name) { $attr = 'meta_' . $name; \Yii::$app->view->registerMetaTag(['name' => $name, 'content' => strlen($model->{$attr}) > 0 ? $model->{$attr} : Yii::$app->keyStorage->get('frontend.' . $attr)], $name); } $viewFile = $model->view ?: 'view'; return $this->render($viewFile, ['model' => $model]); }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Article::find(); if (!\Yii::$app->user->can('administrator')) { $query->forDomain(); } $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]); return $dataProvider; }
/** * Creates data provider instance with search query applied. * * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = Article::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 30]]); $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(['id' => $this->id, 'status' => $this->status, 'category_id' => $this->category_id, 'author_id' => $this->author_id, 'updater_id' => $this->updater_id, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'preview', $this->body]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Article::find(); $query->joinWith(['author']); if (!\Yii::$app->user->can('administrator')) { $query->forDomain(); } $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'domain_id' => $this->domain_id]); if ($this->search_date_published != '') { $this->data_begin_published = strtotime($this->search_date_published); $this->data_end_published = strtotime($this->search_date_published) + 24 * 60 * 60; } $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'user.username', $this->author])->andFilterWhere(['between', 'article.published_at', $this->data_begin_published, $this->data_end_published])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]); return $dataProvider; }
/** * Creates a new Article model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { foreach (Yii::$app->params['availableLocales'] as $key => $value) { $currentModel = Article::getLocaleInstance($key); $currentModel->locale = $key; if (Yii::$app->request->get('scenario')) { $currentModel->on_scenario = Yii::$app->request->get('scenario'); } $models[$key] = $currentModel; } //set data from default model if (Yii::$app->request->get('locale_group_id')) { $defaultDomainModels = Article::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale_group_id' => Yii::$app->request->get('locale_group_id')])->all(); foreach ($defaultDomainModels as $key => $value) { if (!in_array($value->locale, array_keys(Yii::$app->params['availableLocales']))) { continue; } $models[$value->locale]->slug = $value->slug; $models[$value->locale]->title = $value->title; $models[$value->locale]->head = $value->head; $models[$value->locale]->body = $value->body; $models[$value->locale]->thumbnail = $value->thumbnail; $models[$value->locale]->categoriesList = $this->getCategoriesListIds($value->id); $models[$value->locale]->before_body = $value->before_body; $models[$value->locale]->after_body = $value->after_body; } } $model = new MultiModel(['models' => $models]); if ($model->load(Yii::$app->request->post()) && Article::multiSave($model)) { return $this->redirect(['index']); } else { switch (Yii::$app->request->get('scenario')) { case 'extend': $viewName = 'extend'; break; default: $viewName = 'create'; } return $this->render($viewName, ['model' => $model, 'categories' => ArticleCategory::find()->orFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId')])->orFilterWhere(['domain_id' => \Yii::$app->user->identity->domain_id])->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]); } }
public function actionGenerate() { $webUrl = Yii::getAlias('@frontendUrl'); // проверка наличия слеша в конце ссылки if (!StringHelper::endsWith($webUrl, '/', false)) { $webUrl .= '/'; } $webPath = Yii::getAlias('@frontend/web/'); // create sitemap $sitemap = new Sitemap($webPath . 'sitemap.xml'); // add some URLs foreach (Article::find()->published()->all() as $item) { $sitemap->addItem($webUrl . 'article/' . $item->slug, time(), Sitemap::DAILY); } // write it $sitemap->write(); // get URLs of sitemaps written $sitemapFileUrls = $sitemap->getSitemapUrls($webUrl); // create sitemap for static files $staticSitemap = new Sitemap($webPath . 'sitemap_static.xml'); // add some URLs $staticSitemap->addItem($webUrl . 'article/index'); $staticSitemap->addItem($webUrl . 'site/contact'); // write it $staticSitemap->write(); // get URLs of sitemaps written $staticSitemapUrls = $staticSitemap->getSitemapUrls($webUrl); // create sitemap index file $index = new Index($webPath . 'sitemap_index.xml'); // add URLs foreach ($sitemapFileUrls as $sitemapUrl) { $index->addSitemap($sitemapUrl); } // add more URLs foreach ($staticSitemapUrls as $sitemapUrl) { $index->addSitemap($sitemapUrl); } // write it $index->write(); Console::output('The sitemap generated successfully.'); }
/** * redis保存文章浏览数,定时同步到数据表 * `crontab -e` * `0 2 * * * yii article/sync-view` */ public function actionSyncView() { $redis = \Yii::$app->redis; $keys = $redis->keys('article:view:*'); foreach ($keys as $v => $key) { $id = join('', array_slice(explode(':', $key), -1)); $article = Article::find()->where(['id' => $id])->one(); if (empty($article)) { $redis->del($v); continue; } $view = $redis->get($key); // 更新浏览数 if ($article->view < $view) { $article->view = $redis->get($key); $article->save(false); } else { $redis->set($v, $article->view); } } }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Article::find()->published(); $dataProvider = new ActiveDataProvider(['query' => $query]); //q=word if (!empty($params['q'])) { $q = $params['q']; //$q="иб"; //$query2=Article::find(); //$query2->andWhere(['LIKE', 'title', $q]); //$t=$query2->all(); $query->andWhere(['LIKE', 'title', $q])->orWhere(['LIKE', 'body', $q]); return $dataProvider; } if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'category_id' => $this->category_id]); $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * 获取文章列表(可以按分类、标签获取文章列表) * @return string */ public function actionIndex() { $category_id = Html::encode(Yii::$app->request->get('category_id')); $tag_id = Html::encode(Yii::$app->request->get('tag_id')); $data = Article::find()->where(['status' => Article::STATUS_DISPLAY, 'category_id' => $category_id]); if ($tag_id) { $article_tags = ArticleTag::find()->where(['tag_id' => $tag_id])->all(); $article_ids = ArrayHelper::getColumn($article_tags, 'article_id'); $data = $data->andWhere(['in', 'id', $article_ids]); } $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => 20]); //全部文章 $articles = $data->orderBy(['publish_at' => SORT_DESC])->offset($pages->offset)->limit($pages->limit)->all(); //推荐文章 $recommendArticles = Article::getRecommendArticle(); //分类 $categories = Category::find()->where(['status' => Category::STATUS_DISPLAY])->all(); //热门标签 $tags = Tag::find()->orderBy(['article_count' => SORT_DESC, 'id' => SORT_DESC])->limit(10)->all(); return $this->render('index', ['articles' => $articles, 'recommendArticles' => $recommendArticles, 'categories' => $categories, 'tags' => $tags, 'category_id' => $category_id, 'tag_id' => $tag_id]); }
public static function getMetaTags() { $tags = []; $locale = null; preg_match('/^(.+)\\/(.+)\\/(.+)\\/(.+)/', Yii::$app->request->pathInfo, $matches); if (!empty($matches[1]) and !empty($matches[2]) and !empty($matches[3])) { $shortLocale = $matches[1]; $controller = $matches[2]; $action = $matches[3]; $slug = $matches[4]; foreach (Yii::$app->params['availableLocales'] as $k => $v) { if ($shortLocale == explode('-', $k)[0]) { $locale = $k; } } switch ($controller) { case 'page': $model = self::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'article': $model = Article::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'project': $model = Project::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; } //hardcore :) json to array if (!empty($model) and !empty($model->head)) { $arr = json_decode($model->head, true); foreach ($arr as $key => $value) { foreach ($value as $key2 => $value2) { $tags[] = $value2; } } } Yii::$app->view->title = $model->title; } return $tags; }
public function actionIndex() { $article = Article::find()->orderBy(['date_time' => SORT_DESC])->one(); if ($article->articlePhotos[0]->photo_path == '') { if (Yii::$app->language == 'ru') { $articleimage = Yii::getAlias('@resource/img/news_ru.jpg'); } else { $articleimage = Yii::getAlias('@resource/img/news_en.jpg'); } } else { $articleimage = $article->articlePhotos[0]->photo_path; } $event = Event::find()->orderBy(['start_timedate' => SORT_ASC])->limit(3)->all(); $section = Section::find()->limit(8)->all(); $innovation_text_on_main_page = Setting::find()->where(['key' => 'innovation_text_on_main_page'])->one(); $cooperation_with_aic = Setting::find()->where(['key' => 'cooperation_with_aic'])->one(); $fill_in_the_blank = Setting::find()->where(['key' => 'fill_in_the_blank'])->one(); $find_out_how_we_can_help_you = Setting::find()->where(['key' => 'find_out_how_we_can_help_you'])->one(); $information_for_Students = Setting::find()->where(['key' => 'information_for_Students'])->one(); $for_scientists_and_enterpreneurs = Setting::find()->where(['key' => 'for_scientists_and_enterpreneurs'])->one(); return $this->render('index', ['article' => $article, 'articleimage' => $articleimage, 'event' => $event, 'section' => $section, 'innovation_text_on_main_page' => $innovation_text_on_main_page->settingLan->index, 'cooperation_with_aic' => $cooperation_with_aic->settingLan->index, 'fill_in_the_blank' => $fill_in_the_blank->settingLan->index, 'find_out_how_we_can_help_you' => $find_out_how_we_can_help_you->settingLan->index, 'information_for_Students' => $information_for_Students->settingLan->index, 'for_scientists_and_enterpreneurs' => $for_scientists_and_enterpreneurs->settingLan->index]); }
public function actionView($id) { $model = Article::find()->where(['id' => $id])->one(); if (is_null($model)) { // 404 HTTP status will be returned throw new \yii\web\NotFoundHttpException(); } /* * Количество просмотров считается отдельно для русской и отдельно для английской версии */ $article_ru = Article_ru::find()->where(['article_id' => $id])->one(); $article_en = Article_en::find()->where(['article_id' => $id])->one(); if (Yii::$app->language == 'en') { $article_en->visited++; $article_en->save(); } elseif (Yii::$app->language == 'ru') { $article_ru->visited++; $article_ru->save(); } $photos = Article_photo::find()->where(['article_id' => $id])->all(); return $this->render('view', ['model' => $model, 'photos' => $photos]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Article::find()->where(['in', 'status', [Article::STATUS_HIDDEN, Article::STATUS_DISPLAY]]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } if ($this->publish_at) { $query->andFilterWhere(['like', 'publish_at', $this->publish_at]); } if ($this->title) { $query->andFilterWhere(['like', 'title', $this->title]); } if ($this->author) { $query->andFilterWhere(['like', 'author', $this->author]); } if ($this->category_id) { $query->andFilterWhere(['category_id' => $this->category_id]); } return $dataProvider; }