示例#1
0
 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]);
     }
 }
示例#2
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }