groupBy('id')->orderBy('id DESC') ; $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize'=>18]); $pages->forcePageParam = false; $pages->pageSizeParam = false; $news = $query->offset($pages->offset) ->with(['comments.rating', 'averageRating']) ->limit($pages->limit) ->all(); return $this->render('index', [ 'pages'=>$pages, 'news'=>$news, ]); } public function actionShow(){ if(!$news = Articles::find()->where(['id'=>$_GET['id']])->one()) throw new HttpException(404, 'Данной странице не существует!'); return $this->render('show', [ 'news'=>$news, ]); } }