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

Fix desc order in paginate. #285

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MostafaRabia
Copy link

@MostafaRabia MostafaRabia commented Sep 3, 2020

Order desc was sorting per page, not like real pagination, now it's working with me well.

fix for #260

Order desc was sorting per page, not like real pagination, now it's working with me well.
That's better, the perv if the paginate 20 and last page has 4 results won't get them.
There is changes i don't understand it, but it works to me like in charm, get all IDs then order them in paginate, no more "rsort" or something else.
But i don't understand "keyBy($model->getKeyName())", if my pagination IDs is:
10
9
3
By "keyBy($model->getKeyName());" turns to:
3
9
10

So i deleted it and the:
return $models->newCollection($results['ids'])->map(function ($hit) use ($models) {
            if (isset($models[$hit])) {
                return $models[$hit];
            }
        })->filter()->values();
too, and it's working now, working too if your pagination not in default name "page".
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

Successfully merging this pull request may close these issues.

1 participant