Skip to content

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

@ismailnakkar

Description

@ismailnakkar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions