Filament Demo shop_category_product, how does it work?
I've checked out the migration files of the three tables "shop_categories", "shop_category_product" and "shop_products".
I've noticed that in the "shop_products" & "shop_categories" there are no foreign id field for each other but instead in the model of those two tables, they have a BelongsToMany relationship with "shop_category_product". and at that table seems to be where magic happens where it foreign id to both the primary id of "shop_products" & "shop_categories" as its primary key.
What I don't understand is how it seem to still perfectly all connected by showing the categories attached to the product while in the product table there's no categories field. Like how does the "shop_category_product" table updates when a new attachment of a category on a product is added and how it is shown in the Forms of of "ProductResource.php"
This seem to be the magic of the code but I can't find out how it works playing around.
I've noticed that in the "shop_products" & "shop_categories" there are no foreign id field for each other but instead in the model of those two tables, they have a BelongsToMany relationship with "shop_category_product". and at that table seems to be where magic happens where it foreign id to both the primary id of "shop_products" & "shop_categories" as its primary key.
What I don't understand is how it seem to still perfectly all connected by showing the categories attached to the product while in the product table there's no categories field. Like how does the "shop_category_product" table updates when a new attachment of a category on a product is added and how it is shown in the Forms of of "ProductResource.php"
This seem to be the magic of the code but I can't find out how it works playing around.