title: Laravel 5.1 - get data from database group by id and sum values
body: <p>Im not sure how to go about this, i need to get data from a table and sum the values of each field together where the ID is the same.</p>
  
  <p><strong>Things I Have Tried</strong></p>
  
  <ul>
  <li>Pulled all data and tried to store duplicates in array then sort it like that</li>
  </ul>
  
  <p><code>$users = User::all();</code></p>
  
  <pre><code>   $array = [];
      foreach($users as $user)
          {
              array_push($array, [$user-&gt;account_id =&gt; $user-&gt;amount]);
          }
  </code></pre>
  
  <ul>
  <li>Use laravel collections to store the array data and sort it through there</li>
  </ul>
  
  <p>Other than that im not too sure how to go about this! Here is the data that i pull from the database.</p>
  
  <pre><code>0: {1: 100.00}
  1: {1: 100.00}
  2: {2: 100.00}
  3: {2: 100.00}
  </code></pre>
  
  <p>This is the output i want</p>
  
  <pre><code>0: {1: 200.00}
  1: {2: 200.00}
  </code></pre>
  
  <p>This is all i need nothing else I feel like its really simple but I have no clue, any help and guidance will be appreciated, any further information needed will be provided.</p>