by using a polymorphic relationship?
https://laravel.com/docs/10.x/eloquent-relationships#polymorphic-relationships
I am trying to figure out how a relationship can return a collection of models, where the model depends on the "type" column.
I have an Entity class
abstract class Entity extends Model{
}
and 2 implementations:
class Video extends Entity{
}
class Book extends Entity{
}
How can I have a polymorphic relation so that I could do $owner->entities() and it would return me a collection of the corresponding models (which can be a mix of Video and Book instances).
Please or to participate in this conversation.