Closed renege closed 2 years ago
return User::query()->get()->fastPaginate();
return new UserCollection( User::query()->get()->fastPaginate());
return new UserCollection( User::all()->fastPaginate());
You're paginating after the query has already run. You should paginate the query itself!
return User::query()->fastPaginate();
I would add that on fresh Laravel 8/9 projects, it works but on an existing Laravel 8 project of mine it throws a similar issue. I'm assuming there's probably a package(s) messing with it. Anyone running into this should double check existing packages or possible overrides being set somewhere.
@garethnic wait it works on the collection? That's... interesting. I might have to look into this then!
My bad on the clarity part. return User::query()->fastPaginate();
works on fresh installations of Laravel 8/9. Installing in one of my old Laravel (8.83.23) projects is where the issue comes in. Though I experienced it complaining about not finding the service provider. The project being a few years old, it has a bunch of packages and overrides going on so it would be a deep to figure out the root cause.
I tried to implement a fastPaginate
on the Collection class, but unfortunately there's no paginate
to model fastPaginate
after. There is a forPage
but that's kinda different. So I don't think there's much I can do here. Thanks for opening the issue though! Lemme know if you need anything else.
Hi @aarondfrancis,
Promising package!
But I installed it on my Laravel 9 project (
composer require hammerstone/fast-paginate
).And tries to run all 3 options:
And keep getting: