Closed pedrosalpr closed 6 years ago
Interested in this too; slightly different use case but requires similar functionality. I have a table with version numbers (following symver) so basic SQL sorting doesn't result in the correct ouput.
What I do have though is a pre-calculated sort order column (that isn't presented in the api output), so when a user asks to sort by version
I really want to sort by build
at the server.
Custom sorting classes would be great to build this kind of queries:
$query->orderByRaw('`title`->>"$.fr" COLLATE utf8mb4_unicode_ci ASC')
Perfect for spatie/laravel-translatable, because MySQL’s JSON fields are collated to utf8(mb4)_bin
, not useful for multilingual sorting. What do you think?
Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
I would like to know how do I sort by an attribute that is mapped differently in the database?
In my database, the
km
field exists, and when I return to the user I use classResource
and return this field asdistance
.If it were to filter for example, this attribute, I would use
Filter::custom
.But how would I order by
distance
?Because if I order this way it gives an error:
SQLSTATE [42S22]: Column not found: 1054 Unknown column 'distance' in 'order clause'