I would have a look at this blog
It discusses how to use a single user model but extending it fit the other types, e.g. admin, regular user. Using this approach allows you to keep you simple relationship to company, etc
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 types of users which can login in system, I have created separated tables for them b/c they have different fields/data from each other.I have passed user_id which is primary key in users table as foreign key in customers and company table
users(id,email,password,user_type)
customers(id,user_id,first_name,last_name,etc,etc)
company(id,user_id,company_name,address,etc)
I have two other tables
services(id,name)
company_service(id,company_id,service_id)
The problem is that How i should make eloquent relationships among these tables as I can get the information like user profile from related table or company's services etc.
class User extends Authenticatable
public function customer(){
return $this->hasOne('\App\Customer');
}
public function company(){
return $this->hasOne('\App\Company');
}
}
class company extends Model{
return $this->hasMany('App\Service')
}
Please or to participate in this conversation.