title: Laravel hasManyThrough
body: <p>I'm struggling to get my head around a hasManyThrough concept with laravel.
  I have three tables:</p>
  
  <pre><code>Bookings
      -id (int)
      -some other fields
  
  Meta
      -id (int)
      -booking_id (int)
      -metatype_id (int)
      -some other fields
  
  MetaType
      -id (int)
      -name (string)
      -some other fields
  </code></pre>
  
  <p>What I am trying to get is an Eloquent model that allows me to have a single booking record with multiple Meta records of type MetaType. I thought that hasManyThrough might have solved this, but now I am thinking that perhaps this is not the best way.</p>
  
  <p>In my booking model I have</p>
  
  <pre><code>public function bookingmeta() {
      return $this-&gt;hasMany('bookingmeta','booking_id');
  }
  
  public function bookingmetatype() {
      return $this-&gt;hasManyThrough('bookingmetatype','bookingmeta','booking_id','bookingmetatype_id');
  }
  </code></pre>
  
  <p>But this fails to generate the correct SQL and fails. I get</p>
  
  <pre><code>select `new_bookingmetatype`.*, `new_bookingmeta`.`booking_id` 
  from `new_bookingmetatype` 
  inner join `new_bookingmeta` 
  on `new_bookingmeta`.`bookingmetatype_id` = `new_bookingmetatype`.`id` 
  where `new_bookingmeta`.`booking_id` in (57103)
  </code></pre>
  
  <p>Whereas what I am really trying to achieve is</p>
  
  <pre><code>select `new_bookingmetatype`.*, `new_bookingmeta`.`booking_id` 
  from `new_bookingmetatype` 
  inner join `new_bookingmeta` 
  on `new_bookingmeta`.`id` = `new_bookingmetatype`.`bookingmetatype_id`  
  where `new_bookingmeta`.`booking_id` in (57103)
  </code></pre>
  
  <p>If anyone can point me in the right direction I'd really appreciate it. Thanks.</p>