title: Laravel: Get number of occurrences in table
body: <p>I have this query in <code>Laravel</code>:</p>
  
  <pre><code>Models::select('*')-&gt;group_by('user_name')-&gt;order_by(DB::raw('count(user_name)'), 'desc')-&gt;take(3)-&gt;get();
  </code></pre>
  
  <p>It returns <strong>top 3 users</strong> by the number they appear in the table. <br>
  <strong>Q:</strong> How can I also get the count parameter(how many times they appear?)</p>
  
  <p>Current response:</p>
  
  <pre><code>array(
      "Tim","John","Luke"
  );
  </code></pre>
  
  <p>I need something like this:</p>
  
  <pre><code>array(
      array(
          "user" =&gt; "Tim",
          "count" =&gt; 3
      ),
      array(
          "user" =&gt; "John",
          "count" =&gt; 2
      ),
      array(
          "user" =&gt; "Luke",
          "count" =&gt; 1
      )
  );
  </code></pre>
  
  <p>Thanks!</p>