title: Laravel order table by different table column
body: <p>So i have the table Threads and the table Comments, I want to sort threads by the last comment inserted in something like comments.created_at, how I do this?</p>
  
  <pre><code>    $threads = Thread::where('subboaId', $id)
             -&gt;orderBy('comments.created_at', 'desc')
             -&gt;get();
  </code></pre>
  
  <p>tried this but not working maybe I have to join them or something</p>