<?php
namespace AppHelpers;
use IlluminateContainerContainer;
use IlluminatePaginationLengthAwarePaginator;
use IlluminatePaginationPaginator;
use IlluminateSupportCollection;
class PaginationHelper
{
public static function paginate(Collection $results, $showPerPage)
{
$pageNumber = Paginator::resolveCurrentPage('page');
$totalPageNumber = $results->count();
return self::paginator($results->forPage($pageNumber, $showPerPage), $totalPageNumber, $showPerPage, $pageNumber, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
}
/**
* Create a new length-aware paginator instance.
*
* @param IlluminateSupportCollection $items
* @param int $total
* @param int $perPage
* @param int $currentPage
* @param array $options
* @return IlluminatePaginationLengthAwarePaginator
*/
protected static function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
}
}