jeudi 2 août 2018

Can Laravel models be MULTIPLE polymorphic types?

If a user table has a polymorphic relationship like the following:

Users: - id - userable_id _ userable_type

And the User types can be: - App\Student - App\Teacher

QUESTION: How do we handle a user that can be BOTH a student and a teacher? This would happen if a teacher decides to take a lesson from another teacher (perhaps a different topic). We will need to store unique information for this user related to a teacher and a student.

Perhaps this is a case where we just add (nullable) teacher_id and (nullable) student_id columns to the user table?

Thanks,



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OB0Fqa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire