title: How to access table, related to pivot table in whereHas?
body: <p>I have two models <code>One</code> and <code>Two</code>, related via pivot table 'one_two', which has own model <code>OneTwo</code> with hasOne Three.
  Now I want to get all One instances filtered by value in Three.
  This is what I tried and didn't success:</p>
  
  <pre><code>$ones = One::with('twos')-&gt;whereHas('twos', function ($q) {
      $q-&gt;where('threes.value', 'yes');
  })-&gt;get();
  </code></pre>
  
  <p>How to do such thing?</p>
  
  <p>Table <code>ones</code> : <code>id</code>,<code>field1</code></p>
  
  <p>Table <code>twos</code> : <code>id</code>,<code>field2</code></p>
  
  <p>Table <code>one_two</code> : <code>id</code>,<code>one_id</code>, <code>two_id</code>, <code>pivot_field</code>,</p>
  
  <p>Table <code>threes</code> : <code>id</code>, <code>one_two_id</code>, <code>value</code></p>
  
  <p>One &lt;=> Two: many to many</p>
  
  <p>Three => OneTwo: one to one</p>