title: Laravel: Iterate through join collection
body: <p>I have a laravel DB collection which retrieves data using joins. As this:</p>
  
  <pre><code>public static function getAllClientData(){
  
  return DB::table('clients')
      -&gt;join('accounts', 'clients.id',  '=', 'accounts.client_id')
      -&gt;join('addresses', 'clients.address_id',  '=', 'addresses.id')
      -&gt;select('clients.*', 'accounts.*', 'addresses.*')
      -&gt;get();
  }
  </code></pre>
  
  <p>Now I want to get the values of the returned DB collection. However, the table accounts and clients contain both the column "comment". This column is not the same column and contains different values. How can I iterate through the returned DB collection and access/get the value of the specified column?</p>
  
  <p>I have already tried this so far:</p>
  
  <pre><code>foreach($data as $item){
      echo $item-&gt;addresses.comment;
      echo $item-&gt;accounts.comment;
  }
  </code></pre>
  
  <p>However, it is not working. How can I tell Laravel to get the value of the column comment from the table addresses and also next from the table accounts?</p>