title: laravel query with closure
body: <p>I'm trying to query database and make a filter in a closure function, my model (Simplified) looks like this:</p>
  
  <pre><code>Products:
      id,
      sale_id
  
  Sales:
      id,
      provider_id
  
  Provider:
      id
  </code></pre>
  
  <p>I wanna all the products from a specific provider, so i've constructed this my query:</p>
  
  <pre><code>Product::with(array
             ('sale'=&gt;function($query){
                  $query-&gt;where('provider_id', '=', 1);
              })
          )-&gt;get();
  </code></pre>
  
  <p>the problem is that the result contains the right products with the sale, and the wrong products with the sale null, like this:</p>
  
  <pre><code>[{
      "id": 25,
      "sale": null
  },
  {
      "id": 26,
      "sale": {
          "id": 15,
          "provider_id": 3
      }
  }]
  </code></pre>
  
  <p>products with sale:null are the products from another provider, I could filter them in memory, but I think there is a way to avoid the null results from the query, any clue?</p>