title: How to use 'Where Not In' in Laravel 5.4?
body: <p>I'm trying to create a query where I get data from a table and I use INNER JOIN and Where Not In, I was able to adapt the INNER JOIN part, but in 'WHERE NOT IN' I tried using 'WhereNotIn' from Laravel 5.4. But it returns the error: Invalid argument supplied for foreach()</p>
  
  <pre><code>SELECT
          em.erp_mlbid AS category_id
  
              FROM 
                  erp_product AS ep
              INNER JOIN
                  erp_product_category AS epc ON epc.erp_productid = ep.erp_productid
              INNER JOIN
                  erp_mlbcategory_erpcategory AS emc ON emc.erp_categoryid = epc.erp_categoryid
              INNER JOIN
                  erp_mlb_category AS em ON em.erp_mcid = emc.erp_mlbcategoryid    
              WHERE
                  ep.erp_productid NOT IN (
                          SELECT
                              epm.erp_productid
                          FROM
                              erp_product_to_mlb AS epm
                  )
                  AND ep.erp_quantity &gt; 0
                  AND ep.erp_status &gt; 0
              LIMIT
                      10,10
  </code></pre>
  
  <p>So I created this in my application:</p>
  
  <pre><code>$categoria = DB::table('erp_product')
                              -&gt;join('erp_product_category','erp_product_category.erp_productid', '=', 'erp_product.erp_productid')
                              -&gt;join('erp_mlbcategory_erpcategory', 'erp_mlbcategory_erpcategory.erp_categoryid', '=','erp_product_category.erp_categoryid')
                              -&gt;join('erp_mlb_category', 'erp_mlb_category.erp_mcid', '=', 'erp_mlbcategory_erpcategory.erp_mlbcategoryid')
                              -&gt;select('erp_mlb_category.erp_mlbid')
                              -&gt;whereNotIn('erp_product.erp_productid', function($query){
                                  $query-&gt;select('erp_productid')
                                         -&gt;from('erp_product')
                                         -&gt;where('erp_productid', '=', 'erp_product_category.erp_productid');
                              })
                              -&gt;get();
  </code></pre>
  
  <p>Any suggestion?</p>