[英]laravel new many to many relation with pivot table
嗨,我有一張多對多關系的表。
樞紐
id | name
country_hub
hub_id | country_id
國家
id | name
和另一張桌子
類別
id | name
類別屬於hub_id
和country_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.