In your case you have a simple polymorphic relation between users and other tables. You need morphTo in users (with 2 fields like userable_id and userable_type to get id and type from the other table) and morphMany in the others.
Nov 24, 2014
4
Level 2
is this polymorphic relationship or DB design issue ?
There are separate models for students, lecturers, coordinators and all of them are users. I can't figure out the relationship.
Level 3
Check out this blog post by Richard Bagshaw he sums a good approach pretty neatly. Going to be implementing this in a project I'm just starting and it sounds like it fits the bills for you too
http://richardbagshaw.co.uk/blog/laravel-user-types-and-polymorphic-relationships/
1 like
Please or to participate in this conversation.