$query, 'pagination' => [ 'pageSize' => 3, ], 'sort' => [ 'defaultOrder' => [ 'date' => SORT_DESC, ] ], ]); return $this->render('index', [ 'dataProvider' => $dataProvider, ]); } /** * Display one article page. * @return string */ public function actionView($id) { $model = $this->findModel($id); return $this->render('view', [ 'model' => $model, ]); } private function findModel($id) { $model = Articles::findOne($id); if(!empty($model)) { return $model; } else { throw new NotFoundHttpException(); } } }