adonis-lucid-polymorphic
adonis-lucid-polymorphic copied to clipboard
morphToMany / morphedByMany ?
As far as I can tell this is not already supported...
Can we add the ability to define a pivot table for polymorphic relations?
For the use case of; a single shared list of tags, that can be applied to multiple content types.
ie:
tags:
- technology
- science
- entertainment
content types:
- blog post
- video
- article
multiple blog posts, videos and articles might all be tagged with 'science' but 'science' should only exist as a tag one time, and simply be referenced multiple times as one does with a regular many to many relationship utilizing a pivot table.
I suppose a workaround might be just to make the 'taggable' pivot table an actual model, and then setup 1:many relationships between it and tags, and regular polymorphic relations between taggable and the various content types.
Would be nice to not have to make taggable a model though. Here's an example of how it's done in laravel for reference: https://itsolutionstuff.com/post/laravel-many-to-many-polymorphic-relationship-tutorialexample.html
@willvincent It's planned in next release. At the moment, it was necessary to provide support for adonis framework 4.1.x. Thanks for feedback.
Hey @enniel would you like if I write a PR for this?
@jpcbarros @willvincent have any of you found any workarounds for this situation?