title: Display total amount for a charity in Laravel 5.2
body: <p>I have a charity_donations table which holds a charity_id, amount donated for that charity, among other fields. This is how it looks.</p>
  
  <p><a href="https://i.stack.imgur.com/bn5wd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bn5wd.png" alt="Charity Donations Table"></a></p>
  
  <p>What I need to do is I need to groupBy each charity ID, then count how much money was donated for that particular charity. And most importantly, I need to display that in a view.</p>
  
  <p>Some thing like this:</p>
  
  <p>Charity ID | Total</p>
  
  <p>1          | $1,200
  ....</p>
  
  <p>I have tried this,</p>
  
  <pre><code> $displayPerCharity = CharityDonation::select(DB::Raw('charity_id, COUNT(*) as              count'))-&gt;groupBy('charity_id')-&gt;get();
  
          dd($displayPerCharity);
  </code></pre>
  
  <p>That counts the charity IDs, then gives me the total for each charity. But I need total amount for each charity, then display in view.</p>