title: whereHas vs join -> applying global scopes
body: <p>I have a query with a few joins and global scopes for each model, for example:</p>
  
  <pre><code>SELECT *
  FROM products p
  WHERE EXISTS(
    SELECT *
    FROM orders o
    WHERE o.user_id = 4
    AND o.status_id = 1
    AND o.user_id = 3
    AND EXISTS(
      SELECT *
      FROM suborders s
      WHERE s.status_id = 2
    )
  );
  </code></pre>
  
  <p>This means that I can simply write a few <code>whereHas</code> statements and my query will have some nested <code>EXIST</code> clauses, but all global scopes (like the <code>user_id</code> on the <code>orders</code> table) will be applied automatically: </p>
  
  <pre><code>$this-&gt;builder-&gt;whereHas('orders', function ($q) {
    $q-&gt;where('status_id', '=', 1)
      -&gt;whereHas('suborder', function ($q) {
        $q-&gt;where('status_id', '=', 2);
      });
  });
  </code></pre>
  
  <p>The problem is that it's slow, it would be much better to have something with plain <code>JOIN</code>s instead of ugly nested <code>EXIST</code> clauses:</p>
  
  <pre><code>SELECT *
  FROM products p
  INNER JOIN orders o ON p.order_id = o.id
  INNER JOIN suborders s ON o.id = s.order_id
  WHERE o.status_id = 1
  AND u.user_id = 3
  AND s.status_id = 2;
  </code></pre>
  
  <p>The problem with this is that I need to use query builder to join these:</p>
  
  <pre><code>$this-&gt;builder-&gt;join('orders', 'products.order_id', '=', 'orders.id')
                -&gt;join('suborders', 'orders.id', '=', 'suborders.order_id')
                -&gt;where('orders.status_id', 1)
                -&gt;where('suborders.id', 2);
  </code></pre>
  
  <p>And that will not include any of my global scopes on <code>Order</code> and <code>Suborder</code> model. I need to do it manually:</p>
  
  <pre><code>$this-&gt;builder-&gt;join('orders', 'products.order_id', '=', 'orders.id')
                -&gt;join('suborders', 'orders.id', '=', 'suborders.order_id')
                -&gt;where('orders.status_id', 1)
                -&gt;where('suborders.id', 2)
                -&gt;where('orders.user_id', 3);
  </code></pre>
  
  <p>It's bad, because I need to replicate my global scopes logic every time I write a query like this, while <code>whereHas</code> applies them automatically.</p>
  
  <p>Is there a way to join a table, and have all global scopes from the joined model applied automatically?</p>