Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

milroy's avatar

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.

0 likes
4 replies
bestmomo's avatar

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.

NoorDeen's avatar

first path : you can relate all the Entities to user as polymorphic relation .

second path to use multi auth package which will allow you to use any of this Entities as User with Laravel authentication system .

bestmomo's avatar

I thought you had a 1:n relation between your tables, but actually it's a 1:1, so you need morphOne.

Please or to participate in this conversation.