Pagination + Postgres + Order By = help.
Hi,
So I'm using postgres driver, this is an issue related to Order By and aggregated functions. So when I attempt to make a paginator on an orderder query(Eloquent, Relation or QB), I have this abstracted in a repository pattern, so any of these could require a pagination. I tried to send back sorted results, and I came up with the issue. Currently I have a horrible workaround and would be nice to have a better approach.
Current: Check if its instance of relation or eloquent Builder.
Use provided methods to get the underlying querybuilder.
Store the query builders orders array in another variable.
Set the querybuilder order array to NULL.
Get the count.
Restore query builder orders property to original value.
Even though this works, its really hacky, a better approach would be to wrap the query in an alias, and then perform count on it, but haven't found a non hacky way to do it.
Model and sorted column name changes(this is abstracted from concrete class). Any suggestion would be awesome!
Please or to participate in this conversation.