title: Laravel sum eloquent collection
body: <p>How can i sum a data set that has been eager loaded?</p>
  <p>This is my table structure:</p>
  <pre><code>regions table
  +------------+------------------+------+-----+---------------------+----------------+
  | Field      | Type             | Null | Key | Default             | Extra          |
  +------------+------------------+------+-----+---------------------+----------------+
  | id         | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
  | region     | varchar(255)     | NO   |     | NULL                |                |
  | created_at | timestamp        | NO   |     | 0000-00-00 00:00:00 |                |
  | updated_at | timestamp        | NO   |     | 0000-00-00 00:00:00 |                |
  +------------+------------------+------+-----+---------------------+----------------+
  
  submits table
  +------------+------------------+------+-----+---------------------+----------------+
  | Field      | Type             | Null | Key | Default             | Extra          |
  +------------+------------------+------+-----+---------------------+----------------+
  | id         | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
  | region_id  | int(11)          | NO   |     | NULL                |                |
  | deals      | int(11)          | NO   |     | NULL                |                |
  | created_at | timestamp        | NO   |     | 0000-00-00 00:00:00 |                |
  | updated_at | timestamp        | NO   |     | 0000-00-00 00:00:00 |                |
  +------------+------------------+------+-----+---------------------+----------------+
  </code></pre>
  <p>These are my models / relationships :-</p>
  <pre><code>class Region extends Eloquent {
  
    public function submits()
    {
      return $this-&gt;hasMany('Submit');
    }
  
  }
  
  &lt;?php
  
  class Submit extends Eloquent {
  
    public function regions()
    {
      return $this-&gt;belongsTo('Region');
    }
    
  }
  </code></pre>
  <p>This is my controller</p>
  <pre><code>  public function index()
    {
      $regions = Region::with('submits')-&gt;get();
  
      return $regions;
      //return View::make('pages.index', compact('regions'));
    }
  </code></pre>
  <p>This is what the returned data looks like (in json format, i understand $regions in an eloquent collection):-</p>
  <p><img src="https://i.stack.imgur.com/AMpOh.png" alt="raw json" /></p>
  <p></p>
  <p>I can't figure out how i can send the sum total of 'deals' (4) back to the view?</p>