Closed
Description
From my understanding of the Paginator class right now, when you want to use make() to paginate custom data not from Eloquent (in my case it's from Mongo), it doesn't actually handle returning the subset of data to be displayed on the current page.
Current code:
$perPage = 50;
$paginator = Paginator::make($data, count($data), $perPage);
$currentPage = Paginator::getCurrentPage();
$pagedData = array_slice($data, $currentPage * $perPage, $perPage);
// Pass $paginator and $pagedData to view
Wanted code:
// Remove count() call since we could just call it in the make() method
$paginator = Paginator::make($data, $perPage);
// Pass $paginator to view
Then in the view:
@foreach ($paginator->getRows() as $row)
{{ $row->column }}
@endforeach
Currently getItems()
just returns the items you put into the first argument of make()
, so probably add getRows()
or something similar to get the data which would just be an array_slice()
call or similar.
Thoughts? Am I missing something in the current functionality?
Metadata
Metadata
Assignees
Labels
No labels