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

mutaz's avatar
Level 7

Manage the system with multi auth guard...

Hi everyone, i have to build project in laravel and i want to create 3 tables for multi type users ['users','managers','admins'] , i built everything well but i want the same ui form to login and register all type of users how can i do that ???

0 likes
4 replies
vincent15000's avatar

You have put the different types of users in different table ?

That's weird and it's not the usual logic.

Have you any reason not to have roles table and for example add a role_id to the users table ?

1 like
martinbean's avatar

@mutaz You don’t need multiple tables. A user is a user. Use roles to determine what a user can and cannot do based on their role(s).

1 like
mutaz's avatar
Level 7

@martinbean thank you, but what if i use guard to let multible type of users use the system ??

martinbean's avatar

@mutaz I don’t understand why you don’t think “multiple types” of users can use the system if there was a single users table, and your users had roles? You would just check roles instead of horrible, multiple guards logic.

Route::middleware('auth')->group(function () {
    // Front-end routes that all authenticated users can access...
});

Route::middleware('auth', 'role:moderator')->group(function () {
    // Moderators routes that only moderators can access...
});

Route::middleware('auth', 'role:admin')->group(function () {
    // Admin routes that only administrators can access...
});

You don’t need multiple users tables at all.

1 like

Please or to participate in this conversation.