title: How to improve this Laravel query
body: <pre class="lang-php prettyprint-override"><code>$pfilters = ProductFilters
          ::whereIn('Tb_Product_filters.filter_value', $values)
          -&gt;groupBy('Tb_Product_filters.product_id')
          -&gt;join("Tb_Products","Tb_Products.id","Tb_Product_filters.product_id")
          -&gt;join('Tb_Identities', 'Tb_Identities.id', '=', 'Tb_Products.employee_id')
          -&gt;select(
              "Tb_Products.*",
              "Tb_Identities.first_name as fname",
              "Tb_Identities.last_name as lname"
          )
          -&gt;get()
          -&gt;toArray();
  </code></pre>
  
  <p>This query gives me all products witch in the values array , I want only the product in include all values that mean for example </p>
  
  <p>if i have values = <code>[1,2,3]</code></p>
  
  <p>this above statement gives me any product has <code>value_id</code> = <code>1</code> or <code>2</code>,<code>3</code> </p>
  
  <p>I only want the product collect the 3 attrs that mean only the product has <code>value_id</code> = <code>1</code> and <code>2</code> and <code>3</code>  it should search in many rows.</p>
  
  <p>i have 4 tables 
  products 
  filters
  filters_value
  products_filters</p>
  
  <p>first we start with filters </p>
  
  <p>any filter has one or many filters_values 
  example : filter = color ,  filters_value = [red,blue,green] you now the relationship between them depend on filter_id as forgen key </p>
  
  <p>products table: when i create products i will choose product filter and values
  example: iphone = [color:glod, rom:128GB]
  so i will store them in products_filters</p>
  
  <p>products_filter table will contain ; product_id , filter_id , filter_value</p>
  
  <p>so let say i want products with color:red, and rom 64GB  ? </p>