title: Laravel using Sum and Groupby
body: <p>I would like to fetch sum of quantity in each month, so that I can display on bar chart quantities against month </p>
  
  <p>This is what I thought but didn't workout</p>
  
  <pre><code> $data1 = Borrow::groupBy(function($d) {
   return Carbon::parse($d-&gt;created_at)-&gt;format('m')-&gt;sum('quantity');
   })-&gt;get();
  </code></pre>
  
  <p>My table structure</p>
  
  <pre><code>Schema::create('borrows', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;integer('member_id');
          $table-&gt;integer('book_id');
          $table-&gt;integer('quantity');
          $table-&gt;integer('status')-&gt;default(0);
          $table-&gt;timestamps();
      });
  </code></pre>