title: how to order entries by likes of user_id?
body: <p>I'm working on some laravel app and I have a table called "entries", I save in this table recommendations of name for a contest. I need to order the entries based on how many like the user has in total.</p>
  
  <p>this is my table:</p>
  
  <pre><code>id      user_id     contest_id     name               liked
  
  1       1           1              test.com           true
  2       4           1              cool.com           false
  3       1           1              code.com           true
  4       3           1              tool123.com        false
  5       2           1              a23423.com         true
  6       3           1              dole.net           true
  7       1           1              great.com          false
  8       2           1              domain.com         true
  9       2           1              gol.com            false
  10      2           1              greatcode.com      true
  11      2           2              greatco.com        true
  12      2           2              greatmap.com       true
  </code></pre>
  
  <p>this is what I have: </p>
  
  <pre><code>$entries = ContestEntry::where('contest_id', '=', $contest-&gt;id)
  -&gt;orderBy('liked', 'desc')
  -&gt;orderBy('created_at', 'desc')
  -&gt;get();
  </code></pre>
  
  <p>I need to order the entrys by:</p>
  
  <p>a given $contest->id (1st line)
  if the entry is liked or not (2nd line)
  <em>entries where the user has more likes (globally, not the current contest)</em>
  and by created_at(3rd line)</p>
  
  <p>Schema:</p>
  
  <pre><code>Schema::create('contest_entries', function (Blueprint $table) { 
    $table-&gt;increments('id'); 
    $table-&gt;integer('user_id');
    $table-&gt;integer('contest_id');
    $table-&gt;text('name');
    $table-&gt;text('comment')-&gt;nullable();
    $table-&gt;boolean('liked')-&gt;default(false);
    $table-&gt;boolean('available')-&gt;default(true);
    $table-&gt;timestamp('checked_at');
    $table-&gt;timestamps(); 
  });
  </code></pre>
  
  <p>output of "show create table contest_entries":</p>
  
  <pre><code>CREATE TABLE `contest_entries` (
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `user_id` int(11) NOT NULL,
   `contest_id` int(11) NOT NULL,
   `name` text COLLATE utf8mb4_unicode_ci NOT NULL,
   `comment` text COLLATE utf8mb4_unicode_ci,
   `liked` tinyint(1) NOT NULL DEFAULT '0',
   `available` tinyint(1) NOT NULL DEFAULT '1',
   `checked_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
   `created_at` timestamp NULL DEFAULT NULL,
   `updated_at` timestamp NULL DEFAULT NULL,
   PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  </code></pre>
  
  <p>what I need is the table as bellow:</p>
  
  <pre><code>id      user_id     contest_id     name               liked
  
  5       2           1              a23423.com         true
  8       2           1              domain.com         true
  9       2           1              gol.com            false
  10      2           1              greatcode.com      true
  1       1           1              test.com           true
  3       1           1              code.com           true
  7       1           1              great.com          false
  4       3           1              tool123.com        false
  6       3           1              dole.net           true
  2       4           1              cool.com           false
  </code></pre>
  
  <p>as you can see it shows only data from contest_id 1, user_id 2 has 5 liked = true in all contests thats why its entrys are 1st, user_id 1 has 2 liked = true thats why its entrys ar 2nd.. and go on...</p>