aarondfrancis / fast-paginate

A fast implementation of offset/limit pagination for Laravel.
MIT License
1.21k stars 56 forks source link

Can't using pros of Eager Loading #4

Closed yavgel85 closed 2 years ago

yavgel85 commented 2 years ago

When using paginate() -> all fine:

$timelines = Timeline::select('id', 'user_id', 'description', 'created_at')->with('user:id,username')->where('client_id', $client->id)->latest('id')->paginate(10, ['*'], 'timeline');

with() with paginate

But when using deferredPaginate -> it not exclude duplicate queries and models:

$timelines = Timeline::select('id', 'user_id', 'description', 'created_at')->with('user:id,username')->where('client_id', $client->id)->latest('id')->deferredPaginate(10, ['*'], 'timeline');

with() with deferredPaginate

aarondfrancis commented 2 years ago

Making this a package. If you are still running into this, please let me know and we can add a test for it!