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

dotmra's avatar

Multi {User} tables using a single login form

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!

0 likes
7 replies
martinbean's avatar
Level 80

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.

1 like
dotmra's avatar

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/

Thanks for the quick response, will look into it

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.

Thanks, and true a user is a user.

However, as my customer explained to me, there is a hierarchy between user types. Not only different content on the application.

Eg.

A User which type is "dealer" is attached to a User that is a "provider", in such a way that multiple variables on the dealers page is dependent on the choices a provider has made from their side. If the provider is not an eligible user anymore then other default settings go into effect.

That kind of relationship between users can be made as a single table with three columns containing id,dealer_id,provider_id, but is this the way to go when there clearly is a hierarchy?

Snapey's avatar

You are still talking about individuals that might need access to your application. Everything else is just business logic.

1 like
martinbean's avatar

A User which type is "dealer" is attached to a User that is a "provider"

@randomphp You can still model this if you have a single users table.

If a user is a dealer, they might have a “dealer profile” relation. That dealer profile model could then have a foreign key to the user that is that dealer’s provider.

dotmra's avatar

@martinbean I know

My customer was simply looking for alternatives, since they talked about have the usertypes split up between tables and not use a single user table with profile tables.

But thanks for the help :)

Please or to participate in this conversation.