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

EmilMoe's avatar
Level 10

Structuring of users (auth) with multiple types

I have 2 types of users in my project:

  • employees
  • students

Employees will have a lot more information associated and relations than students, I want these relations to be mandatory, but for students they are not there. My initial thought is to create 2 tables, but how do I manage authentication from 2 different tables?

0 likes
5 replies
MohamedTammam's avatar

I suggest you to add a column in the user table to indicate whether the user is employee or not like is_employee, and then do you permission according to that.

1 like
martinbean's avatar

but i would have a lot of relational columns which are null for students

@EmilMoe Instead maybe have a StudentProfile model and an EmployeeProfile model. You can then add a polymorphic profile relation to your User and you can then determine what “type” of user they are based on the profile associated with them. It’s also extensible should you wish to add a new type of “profile” in the future, such as teachers or parents.

Please or to participate in this conversation.