本文整理汇总了PHP中Paginator::getPerPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getPerPage方法的具体用法?PHP Paginator::getPerPage怎么用?PHP Paginator::getPerPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginator
的用法示例。
在下文中一共展示了Paginator::getPerPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: simpleRendeArray
/**
* create pagination with only previous and next buttons
*
* @return array
*/
public function simpleRendeArray()
{
$array = [];
$count = $this->paginator->getCount();
$url = $this->path;
$current = $this->paginator->getCurrentPage();
// create appends string
$appends = $this->createAppendString($this->paginator->getAppends());
// create fragments string
$fragments = $this->createFragmentsString($this->paginator->getFragments());
if ($count < $this->paginator->getPerPage()) {
$limit = 1;
} else {
$limit = ceil($count / $this->paginator->getPerPage());
}
if ($this->isAvaibleCurrentPage($current) && $current > 1) {
$previous = $current - 1;
$array[] = $this->buildChieldString('Previous', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $previous);
}
if ($this->isAvaibleCurrentPage($current) && $current < $limit) {
$next = $current + 1;
$array[] = $this->buildChieldString('Next', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $next);
}
return $array;
}
示例2: respondWithPagination
/**
* @param Paginator $items
* @param $data
* @return \Illuminate\Http\JsonResponse
*/
protected function respondWithPagination($items, $data)
{
$data = array_merge($data, ['paginator' => ['total_count' => $items->getTotal(), 'total_pages' => ceil($items->getTotal() / $items->getPerPage()), 'current_page' => $items->getCurrentPage(), 'limit' => $items->getPerPage()]]);
return $this->respond($data);
}
示例3: respondWithPagination
/**
* @param Paginator $elements
* @param $data
*
* @return \Illuminate\Http\JsonResponse
*/
public function respondWithPagination(Paginator $elements, $data)
{
$data = array_merge($data, ['paginator' => ['totalCount' => $elements->getTotal(), 'totalPages' => ceil($elements->getTotal() / $elements->getPerPage()), 'currentPage' => $elements->getCurrentPage(), 'limit' => $elements->getPerPage()]]);
return $this->respond($data);
}