So I have a products
table and a categories
table and a pivot
table.
Product (products
)
-- id
-- name
Category (categories
)
-- id
-- name
CategoryProduct (category_product
)
-- category_id
-- product_id
I want to get all products that belong to a certain category, I have managed to get it by doing the following query:
$products = Category::find(3)->products;
But how can I access it off the product model?
$products = Product::?