Have one User model, primarily for authentication but link it to different profile tables using a polymorphic relationship
http://novate.co.uk/using-laravel-polymorphic-relationships-for-different-user-profiles/
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have a customer that asked me a question, I couldn't answer. Which is why I am asking it here.
Problem: My customer has 2-3 different "user types" He wants to spread it out over 2-3 different "user" tables.
Eg. "User", "Dealer", "Admin"
The reason why he wants to spread the users out over 3 tables is because each type have different fields to fill out upon registration.
And he doesn't want to have a lot of clutter in user table.
However, the quick solution I gave him was have user and user_details tables.
So the user table would only have the fields required for login, and the rest in user_details.
But that would result in the same clutter, but in user_details instead of user.
Question: Is it possible to make laravel auth lookup in multiple tables when trying to login, password reset, remember_token etc.?
Eg.
All 3 tables have email, password & remember_token.
Using a single login form (Because every "type" have to use the same page/login form.
FYI. I can imagine my customer adding more user types in the future-
What is the best way of achieving this?
Thanks!
I can imagine my customer adding more user types in the future
@randomphp So you’re just going to keep creating user tables (and guards) for each different user type…?
I see this mistake being made time and time again. A user is a user. If different “types” of users have different fields, then put those fields in dedicated profile tables linked to a user. But all users will have the same columns: name, email, password. You can then use authorisation to restrict what each user “type” can do in your application.
Please or to participate in this conversation.