我有一张products
英镑的桌子.A-product
属于A-category
和A-country
.
我想通过依靠这段关系来找出countries
A category
有什么.
我考虑过hasManyThrough
和https://github.com/staudenmeir/belongs-to-through,但这是一种belongsTo
的关系,两个外键都在一个中间表上,我怀疑products
表的作用有点像一个透视.
我想知道如何通过products
表建立一个从categories
到countries
的关系--这可能吗?
表:
类别
- ID
- 标题
各国
- ID
- 标题
产品
- ID
- 标题
- category_ID
- country_ID
关系:
A product
属于A country
/A country
有许多products
.
A product
属于A category
/A category
有许多products
.