title: Laravel collection by month
body: <p>I've got a collection and I need the total users by month. </p>
  
  <p>So I've done this:</p>
  
  <pre><code>array_replace(array_fill_keys(range(0, 11), 0), $users-&gt;groupBy('created_at.month')-&gt;toArray())
  </code></pre>
  
  <p>It's sort of working because I get this:</p>
  
  <pre><code>array:12 [▼
    0 =&gt; 0
    1 =&gt; 0
    2 =&gt; 0
    3 =&gt; 0
    4 =&gt; 0
    5 =&gt; 0
    6 =&gt; array:1 [▶]
    7 =&gt; array:2 [▶]
    8 =&gt; 0
    9 =&gt; 0
    10 =&gt; 0
    11 =&gt; 0
  ]
  </code></pre>
  
  <p>The problem I face now is that I don't need the 2 arrays at position <code>6</code> and <code>7</code> but I need the counts. </p>
  
  <p>So I was thinking of something like:</p>
  
  <pre><code>$users-&gt;groupBy('created_at.month')-&gt;count()-&gt;toArray();
  </code></pre>
  
  <p>But, that's obviously not working. Any ideas ?</p>