Eloquent relationships laravel

102 Views Asked by At

I have 3 tables

categories

  • id
  • name

categories_product

  • id
  • category_id
  • product_id

and a product table

products

  • id
  • name

I want products based on catergori_id, how kan i do that with laravel Eloquent?

1

There are 1 best solutions below

4
On

Simple as this:

Product::whereCategori_id($category)->get();