title: Trying to aggregate column values in eloquent
body: <p>I have model called Organisation, which has a many to one relationship with a model called Client, it looks like this, </p>
  
  <pre><code>public function clients() {
      return $this-&gt;hasMany('Client', 'owner_id')-&gt;orderBy('name', 'asc');
  }
  </code></pre>
  
  <p>Client has a one to many relationship with projects that looks like this, </p>
  
  <pre><code>public function projects()
  {
      return $this-&gt;hasMany('Project');
  }
  </code></pre>
  
  <p>The project model / table as a column called <code>total_cost</code> within an organisation I can gets it's clients, and then the clients projects, what I wanting to do is get the value of the client by aggregating all the clients projects <code>total_cost</code> entries, I am trying to do this with the following, </p>
  
  <pre><code>public function clientsValue() {
      return $this-&gt;clients()-&gt;projects()-&gt;select(DB::raw("SUM(total_cost) as client_value"));
  }
  </code></pre>
  
  <p>In my mind this getting the projects through the clients relationship and then running a select on the project model, however I am getting the following error,</p>
  
  <pre><code>Call to undefined method Illuminate\Database\Query\Builder::projects()
  </code></pre>
  
  <p>But I am not sure why as the clients has a projects relationship.</p>