Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LengthAwarePaginator returns the total provided regardless of the total actual count of the data #52090

Closed
ismailnakkar opened this issue Jul 11, 2024 · 2 comments

Comments

@ismailnakkar
Copy link

ismailnakkar commented Jul 11, 2024

Laravel Version

11.13

PHP Version

8.3

Database Driver & Version

No response

Description

Paginate should return the correct total (not the total provided by the user when providing one)

Currently the code in paginate is $total = value($total) ?? $this->toBase()->getCountForPagination();

But I believe it should be $total = $total ? min(value($total), $this->toBase()->getCountForPagination()) : $this->toBase()->getCountForPagination();

Steps To Reproduce

Paginate any model, if you choose the total to be 10000, it will return 10000 even if there is less than that in the total count of the model

@crynobone
Copy link
Member

See #46410

@crynobone
Copy link
Member

The $total parameter was added to skip running the default aggregate count query, so this seems to be the expected behavior now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants