Many to Many relationship constrain

table:Products
Product\_id
Category

Table:Features
Feature\_id: 11
Feature\_name: remote

Pivot table : FeatureProduct
Feature\_id
Product\_id

```
$products = App\Product::with([‘features' => function ($query) {
    $query->where(‘id’, 11);
}])->where(‘category_id’, 17)->get();

```

Still get all products with category = 11, not filter out the feature\_id = 11

the :with Query where clause, i don't know what should i put, it is the ID belongs to feature.

This is how a single product output

```
Product {#1372 ▼
  #original: array:13 [▼
    "id" => 1
    "code" => "PL6881"
    "v_description" => "E14 41 bóng + LED pha lê 642 hạt"
    "width" => 1200
    "length" => null
    "height" => 1800
    "price" => 47800000
    "vendor_id" => 1
    "category_id" => 17
    "active" => 1
    "discount" => 0
    "hero" => 0
    "promote" => 0
  ]
  #relations: array:1 [▼
    "features" => Collection {#5858 ▼
      #items: array:3 [▼
        0 => Feature {#3149 ▼
          #attributes: array:4 [▼
            "id" => 3
            "code" => "Chau Au"
            "v_description" => "Châu Âu"
            "att_cate_id" => 1
          ]
        }
        1 => Feature {#3340 ▶}
        2 => Feature {#3492 ▶}
      ]
    }
  ]

}

```