Added ability to have custom sort classes.#91
Added ability to have custom sort classes.#91AlexVanderbist merged 4 commits intospatie:masterfrom gcw07:custom-sort
Conversation
|
Just a note, addSubSelect() is a macro that Jonathan Reinink showed off in his great Laracon Online 2018 talk. His talk repo can be seen here. It is also where the idea for the sub select sorting is from. https://github.com/reinink/laracon2018 |
|
Would be awesome if this could be merged :) |
|
Could you rebase this against the current master? |
|
Sorry, meant to respond earlier today. Yes I can rebase it. Though in my version I had to overwrite (and call the parent class) of several query methods (getQuery, paginate, simplePaginate). I'm not sure if I need to actually overwrite those methods. You only previously overrode the get method. Do you know if the other methods like paginate end up calling get and run the get method within the QueryBuilder class? |
|
Currently working on a project that could use this functionality. Happy to help out if needed. |
|
Would love to see this added! 👍 |
Update fork
Merge branch
|
OK, I merged all the updates that have happened to master back into this pull request. Not sure if I did it correctly or not, but I think it is good. Still wasn't sure if we really need to do all the overriding of methods or if just overriding the "get" method would work. |
|
Thanks, this looks really good! Will take a look at this and probably merge it later this week :) |
|
What about merge? This feature is really useful and I wait for it. |
|
Still waiting on this 😬 @gcw07 I can give a hand with this if you need? I'm conscious if you have enough time to work on this? And myself and others are really looking forward to using it! |
|
@matthew-inamdar I rebased this around a month ago. So it is really up to the maintainers at this point if they want to merge it or implement their own version (either way is fine with me, this was intended more as a proof of concept than anything else). |
|
Sorry for the delay. It's been merged, now going through the broken tests to make sure everything works together with other recently merged PRs. Will tag a new version including these custom sort classes soon |
|
Thanks for the work @gcw07 and @AlexVanderbist 👍 |
|
Thanks for all the work on this. This is going to be extremely helpful for the project I'm working on. |
|
Any news on this? |
|
This was added to one of the latest releases. It has been working great! |
|
There is no docs on README? |
|
can any one please make an example about how to do this without this macro ?? i mean how to sort by relationship values |
|
Where can we find the documentation about this? |
This adds the ability to have custom sort classes. So why would you need or want a custom sort class? Doing so would allow users to sort by related models. Normal usage is the same as before. So if you just want to keep the standard sorting, you just add the sort fields like normal:
So to add a custom sort you would so something like:
And a basic custom class would look like:
Obviously you wouldn't want just a basic custom sort, but something that would be able to sort the related fields. This can be achieved by doing a sub select or you could do a join.
While it passes all tests, this more than anything is a proof of concept. I think it could be improved upon. Let me know what you think. Thanks for providing such a great package.