问题
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:
Simple as this:
Product::whereCategori_id($category)->get();
来源:https://stackoverflow.com/questions/26920372/eloquent-relationships-laravel