laravel join three tables
<p>I have three tables that are as follows:</p>

<p><strong>invent_accessory</strong>
id,code,detail,is_length</p>

<p><strong>invent_price_accessory</strong>
id,invent_accessory_id_fk,price,color</p>

<p><strong>invent_price_accessory_length</strong>
id,invent_accessory_id_fk,price,color</p>

<p>how do i combine these three tables so that i can get <strong>id,code,detal,is_length,price,color</strong></p>

<p>i have done following but it doesnt not return any data:</p>

<pre><code> public function getAccessoryInventPrice(){

  $accessory=DB::table('invent_accessory')
        -&gt;select('invent_accessory.id as accessory_id')
        -&gt;join('invent_price_accessory','invent_price_accessory.invent_accessory_id_fk','=','invent_accessory.id')
        -&gt;join('invent_price_accessory_length','invent_price_accessory_length.invent_accessory_id_fk','=','invent_accessory.id')
      -&gt;get();

  return $accessory;

 }
</code></pre>

<p>I am guessing that I have to do Union between <strong>invent_price_accessory</strong> and <strong>invent_price_accessory_length</strong> first then join with <strong>invent_accessory</strong>? How do i do this? pls help.</p>