Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

It seems that you have to slice manually. From the Laravel 5.1 doc:

"When manually creating a paginator instance, you should manually "slice" the array of results you pass to the paginator."

So the answer is:

$arr = $all->toArray();
$offset = ($currentPage * $perPage) - $perPage;
$arr_splice = array_slice($arr, $offset, $perPage, true);
$paginator = new Paginator($arr_splice, count($arr), $perPage, $currentPage);
0

Sign in to participate in this thread!

Eventy

Your banner here too?

PatrickL patrickl Joined 27 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.