簡體   English   中英

laravel 新的多對多關系與數據透視表

[英]laravel new many to many relation with pivot table

嗨,我有一張多對多關系的表。

樞紐

id  |  name

country_hub

hub_id  |  country_id

國家

id  |  name   

和另一張桌子

類別

id  |  name

類別屬於hub_idcountry_id組合,這又是與數據透視表country_hub多對多關系,例如

country_hub_id |  category_id   

請有人建議我如何管理這個。 我應該制作另一個數據透視表category_country_hub以及如何在 Laravel 中實現它?

哪個是好方法

category_country_hub

country_hub_id | category_id

或者

category_country_hub

hub_id  |  country_id | category_id

您所需要的只是刪除類別表。 您可以使用 pivot 方法訪問 country_id 和 hub_id。 也許這將有助於Laravel 的多對多關系文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM