title: Laravel - how to get records with exact match of categories using belongsToMany relation
body: <p><strong>Products</strong>
  <br>
  -id
  <br>
  -title</p>
  
  <p><strong>Categories</strong>
  <br>
  -id
  <br>
  -name</p>
  
  <p><strong>ProductCategories</strong>
  <br>
  -Products_id
  <br>
  -Categories_id</p>
  
  <p>what i would like to achieve is get get all the products with at least matching all selected categories (eg: [1,4,6,9] )</p>
  
  <p>and skip products that has only one or more of matching categories (eg: [6,9])</p>
  
  <p>my code so far ... which displays the products that are needed to skip</p>
  
  <p><strong>relationship</strong></p>
  
  <pre><code>public function productcats()
      {
          return $this-&gt;belongsToMany('App\Categories', 'ProductCategories', 'Products_id ', 'Categories_id');
      }
  
  
  
  $cats = [1,4,6,9];
  
  
  
  Products ::whereHas('productcats', function($query) use ($cats){
                              $query-&gt;whereIn('Categories_id', $cats );
                          })
                          -&gt;paginate(10);
  </code></pre>