Skip to content

OrderBy relationated field #1537

Answered by thetutlage
rodolphonetto asked this question in Help
Discussion options

You must be logged in to vote

Yes coz relationships are loaded in a separate query after the main query. What you need is a order by subquery. Following should do it.

.orderByRaw(
  Database.raw('select title from solicitation_types where solicitation_types.FK = main_table.PK'),
  'desc'
)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rodolphonetto
Comment options

@DZ8540
Comment options

Answer selected by rodolphonetto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants