I have a database that looks like this: Database Graphical Representation
The dance_performer.perfomer_type
field hosts values such at 'AppDancer'
, 'AppCouple'
or 'AppFormation'
.
How would you proceed to connect the dance_performer.perfomer_id
to the different models? I am not sure how I am supposed to write the relationships in the different models.
Should I create a AppPerformer
model which would then direct to one of the three previously mentioned?
I would appreciate the help.
Advertisement
Answer
You are looking for polymorphic
relationships. See documentations https://laravel.com/docs/7.x/eloquent-relationships#polymorphic-relationships