title: Order an Eloquent model by relationship count and then pluck out that count
body: <p>I got this far:</p>
  
  <pre><code>return \App\Project::with('likes')-&gt;get()-&gt;sortByDesc(function($project) {
      return $project-&gt;likes-&gt;count();
  })-&gt;lists(['title', 'likes']);
  </code></pre>
  
  <p>And the desired result is:</p>
  
  <p><code>array('Some title' =&gt; 43, 'Some other title' =&gt; 11)</code></p>
  
  <p>Is this even achievable with Eloquent? Or should I just build up an array <code>'manually'</code>?</p>
  
  <p><strong><em>Edit</em></strong></p>
  
  <p>Basically, I want to achieve the following:</p>
  
  <pre><code>\DB::table('projects')
      -&gt;join('likes', 'projects.id', '=', 'likes.project_id')
      -&gt;select(\DB::raw('title, count(likes.id) as likes'))
      -&gt;groupBy('projects.id')
      -&gt;get();
  </code></pre>
  
  <p>but <code>Eloquent</code> way.. </p>
  
  <p>I also tried setting <code>getLikesCountAttribute</code> method, and now I can do:</p>
  
  <p><code>\App\Project::all()-&gt;sortByDesc('likesCount')-&gt;lists('likesCount', 'title');</code></p>
  
  <p>which works fine, but as you can see - this way I have to retrieve all the records first, and then get that count using the magic <code>getLikesCountAttribute</code> method. Perhaps not that big of a deal, don't know..</p>