⚠️ This post links to an external website. ⚠️
In this article we're going to explore how to order database queries by the value (column) of an Eloquent relationship. For example, maybe we want to order some users by the name of their company, which is in a separate companies table.
The way to do this is different depending on the relationship type. However, it always involves ordering by a column in a separate database table, and that's what makes it somewhat tricky, especially compared to a normal order by. And yet, this is a common enough thing to want to do!
continue reading on reinink.ca
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.