本文整理匯總了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);
}