mercredi 16 mars 2016

Convert raw SQL to use Laravel Pivot Table

I got 3 tables, products, categories, categories_products (pivot). Each product belongs to one or more category. How can I show products under a specific category

a raw SQL example would be

SELECT *
FROM categories_products
INNER JOIN products ON categories_products.product_id = products.id
INNER JOIN categories ON categories_products.category_id = categories.id
AND categories.category_name = 'desks'



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire