So I have a products table and a categories table and a pivot table.
Product (products)
-- name
Category (categories)
-- 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::?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire