Skip to content

Commit

Permalink
✨ allow the ability to pass a class name and the ability to specify m…
Browse files Browse the repository at this point in the history
…aximum pages
  • Loading branch information
acidjazz committed Apr 11, 2019
1 parent 1d75cc7 commit daa8e66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/MetApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,21 @@ protected function addMeta($name, $value) {
$this->meta[$name] = $value;
}

protected function paginate($collection,$perpage=15) {
protected function paginate($collection,$perpage=15,$maxPages=7) {

$collection = $collection->paginate($perpage);
if (is_string($collection)) {
$collection = $collection::paginate($perpage);
} else {
$collection = $collection->paginate($perpage);
}

$paginator = new Paginator(
$collection->total(),
$collection->perPage(),
$collection->currentPage()
);

$paginator->setMaxPagesToShow(7);
$paginator->setMaxPagesToShow($maxPages);

$pages = [];

Expand Down

0 comments on commit daa8e66

Please sign in to comment.