title: Eloquent: get data for every day of the month
body: <p>I have some troubles with my Eloquent query result formatting. </p>
  
  <p>I have the table Clubs and it stores football clubs. Every record in database has 'brand' value and now I want to return count of column brand values for every day. For example: I added today 9 times "Real" and 40 times "Barcelona" to my table, so I expect return value for every day in the last month like: </p>
  
  <pre><code>[
      {
          "date": "2019-01-12",
          "clubs": {
               "Barcelona": 40,
               "Real": 9
          }
      }
  ] 
  </code></pre>
  
  <p>Instead of that I get:</p>
  
  <pre><code>[
      {
          "date": "2019-01-12",
          "count": 9,
          "brand": "Real"
      },
      {
          "date": "2019-01-12",
          "count": 40,
          "brand": "Barcelona"
      }
  ]
  </code></pre>
  
  <p>There's my controller query:</p>
  
  <pre><code>    $brandsMonthlyInfo = array();
      $dates = collect();
  
      foreach( range( -30, 0 ) AS $i ) {
          $date = Carbon::now()-&gt;addDays( $i )-&gt;format( 'Y-m-d' );
          $dates-&gt;put( $date, 0);
      }
  
      $countAddedBrands = DB::table('Clubs')-&gt;where([['created_at', '&gt;=', $dates-&gt;keys()-&gt;first()]])
      -&gt;groupBy( 'date' )
      -&gt;groupBy( 'brand' )
      -&gt;orderBy( 'date' )
      -&gt;get( [
          DB::raw( 'DATE( created_at ) as date' ),
          DB::raw( 'COUNT(brand) AS "count"' ),
          'brand'
      ] );
  
      return $countAddedBrands;
  </code></pre>
  
  <p>Do you have any idea how to fix that? I really appreciate any help.</p>