示例#1
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     //参数过滤
     $params = Yii::$app->request->queryParams;
     $model = new Post();
     $params = $model->filterParam($params, 'PostSearch');
     $searchModel = new PostSearch();
     $dataProvider = $searchModel->search($params);
     //倒序排列
     $dataProvider->query->orderBy('created_at DESC');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }