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

Rahmonali's avatar

How to login from 2 different tables?

Hello there,

I am new in Laravel. I would like to make a login page and wanna login from 2 different tables. Suppose, my tables would be a student and a teacher. What steps should I take in?

Thank you!!!

0 likes
4 replies
JAY_CHAUHAN's avatar

My suggestion is to make new table called "user_master" and store your crendetial fields like email, password etc...

add one "user_type" field in user_master table to define the user type (like student and teacher).

so this makes a common login form for both user (student and teacher).

when any user authenticate then match that credential with user_master table, after that you identify the user by its "user_type" field and redirect to perticular screen.

2 likes
Snapey's avatar

Why go to the hassle of changing the name of the users table. It just causes more work for no benefit.

Everyone accessing your application is a user. Simple.

1 like
Rahmonali's avatar

@SNAPEY - In each tables there would be differen columns. And in some point I have to show a single teacher how many studens has. In this way I can find out from 2 tables. And I will display this students belog to this teacher.

but if I create a user table and show them with user_type (teacher , student), is here any way to put on display that how many students are there for a teacher?

Please or to participate in this conversation.