Yii2 REST API分页getLinks

时间:2017-09-22 07:11:17

标签: rest api yii2

这是我的代码

$provider = new ActiveDataProvider([
        'query' => $model->getReservations($start_time, $end_time),
        'pagination' => [
             'defaultPageSize' => 2 ,
             'pageSize' => 2,
             'pageSizeLimit' => [1, 2],
         ],
    ]);
return $links = $provider->getLinks();

它给我这个错误

  Calling unknown method: yii\\data\\ActiveDataProvider::getLinks()

我如何获得gpagination的链接

1 个答案:

答案 0 :(得分:0)

首先,您必须通过Pagination方法获取getPagination()个对象。然后,对象Pagination有方法getLinks(),所以:

return $links = $provider->pagination->links;

OR

return $links = $provider->getPagination()->getLinks();