public function run() { $posts = Post::find()->orderBy(['id' => SORT_DESC])->limit($this->count)->all(); if ($posts !== null) { return $this->render('latest-posts.php', ['posts' => $posts]); } }
/** * Lists all Post models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Post::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }