title: I have Product and Category Many to Many Relation. I need to fetch Product where category_id(in pivot table) = [1,2,3,4]
body: <p>I have Product and Category Many to Many Relation. I need to fetch Product where category_id(in pivot table) = [1,2,3,4]</p>
  <p>in my Category Model</p>
  <pre><code>public function all_product($categories_ids): BelongsToMany
  {
      return $this-&gt;belongsToMany(Product::class)-&gt;wherePivotIn('category_id', $categories_ids);
  }
  </code></pre>
  <p>and in controller</p>
  <pre><code>    $categories_ids = [1,2,3,4];
      $category = Category::where('slug_id', $request-&gt;input('slug_id'))-&gt;first();
      $product =  $category-&gt;all_product($categories_ids)-&gt;get();
      return $product;
  </code></pre>
  <p>here I get only associated product with that  $category. but I need all product whose category_id are $categories_ids = [1,2,3,4].</p>
  <p>please help me to solve this query. thank you</p>