Hi i have a table with many to many relation.
hubs
id | name
country_hub
hub_id | country_id
countries
id | name
and another table
categories
id | name
Categories belongs to combination of hub_id
and country_id
which is again a many to many relation to pivot table country_hub
eg
country_hub_id | category_id
Please can anybody suggest me how do i manage this. Should i make another pivot table category_country_hub
and how do i implement it in Laravel?
which one is good approach
category_country_hub
country_hub_id | category_id
OR
category_country_hub
hub_id | country_id | category_id
All you need is to remove the categories table. You can access the country_id and hub_id using the pivot method. Maybe this will helpLaravel's Documentation on Many to Many Relationships
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.