Maybe you can repeat eloquents "Polymorphic Relationships" logic and organize it like this:
Where "model_type" will be mapped to your models:
- App\Post
- App\Podcast
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello I have three tables post podcast Education I have and I want to connect these to the tag table with relationships What I've done now is create a many to many relation to the tag table for each of my tables. To make this question more understandable, my tables are implemented as follows (for now).
post migration for example
id - title - slug - image - created_at - updated_at
tag migration for example
id - name - created_at - updated_at
pivot table (post-tag)
id - post_id - tag_id - created_at - updated_at
It works great now But the problem is, my tables have a similar structure, and I did the exact same thing with another table. for exaple . pivot table (podacst-tag)
id - podcast_id - tag_id - created_at - updated_at
pivot table (education-tag)
id - education_id - tag_id - created_at - updated_at
And I think there's a better way, thank you
Please or to participate in this conversation.