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

Rrrr's avatar
Level 1

login roles different multi table data user

i try to create database design for login

users
	id 
	userable_id
	userable_type

user_role
	user_id
	role_id

roles
	id
	name

companies
	id
	email
	password
	- more detailed information columns...

students
	id
	email
	password
	- more detailed information columns...

admins
	id
	email
	pass

is this the right way?

I'm separating company and student data tables, because later the tables will hold data.

companies and students do not need to register, because the admin will input their data, including email and password.

What method do I need in laravel to handle the login?

0 likes
1 reply
bobbybouwmann's avatar

You have two options with logging users in with different types. That's just using a role in the users table and based on that redirect the user to some kind of page.

Another solution is your solution by using multiple tables. To handle this correctly you need to create custom authentication providers. You can read more about it here: https://medium.com/@sagarmaheshwary31/laravel-multiple-guards-authentication-setup-and-login-2761564da986

Please or to participate in this conversation.