Sorting on related fields?


How do I sort queries by related model field in Lucid? Like select from person p join company c on order by;?
Person.query().with('company').orderBy('') results in ER_BAD_FIELD_ERROR: Unknown column '' in 'order clause'
And so does with('company', q=>'name')) .


Hey @rag! :wave:

If you need to make complicated queries you better want to use a custom join instead of using with.

Also, note that you are using but you should use since the name of the table is companies.