Laravel - Relationships - Many To Many Polymorphic Table Structure
Many-to-many polymorphic relations are slightly more complicated than "morph one" and "morph many" relationships. For example, a
Post model and
Video model could share a polymorphic relation to a
Tag model. Using a many-to-many polymorphic relation in this situation would allow your application to have a single table of unique tags that may be associated with posts or videos. First, let's examine the table structure required to build this relationship:
posts id - integer name - string videos id - integer name - string tags id - integer name - string taggables tag_id - integer taggable_id - integer taggable_type - string
Before diving into polymorphic many-to-many relationships, you may benefit from reading the documentation on typical many-to-many relationships.