title: Laravel relationship error: Undefined property: Illuminate\Database\Eloquent\Collection::$id on line 1
body: <p>I have two models <code>Company</code> and <code>Employee</code>, with corresponding tables in MySQL, <code>companies</code>, and <code>employees</code>. </p>
  
  <p>I have these Many-to-One relationships defined:</p>
  
  <p>In the <code>Company</code> model:</p>
  
  <pre><code> public function employees(){
          return $this-&gt;hasMany('App\Employee','company');
      }
  </code></pre>
  
  <p>In the <code>Employee</code> model: </p>
  
  <pre><code>public function company(){
          return $this-&gt;belongsTo('App\Company','company');
      }
  </code></pre>
  
  <p><code>company</code> above in the methods is an unsigned integer foreign key present in the <code>employees</code> table. </p>
  
  <p>In tinker I have tried <code>$company-&gt;employees;</code>, which returns a list of all the employees in the selected company. However, when I do <code>$company-&gt;employees-&gt;id</code> to get the IDs of all the employees only and not the other rows, it gives me the error: </p>
  
  <pre><code>PHP error:  Undefined property: Illuminate\Database\Eloquent\Collection::$id on line 1
  </code></pre>