appyapp
3 months ago

User and Profile - Different tables and relationship

Posted 3 months ago by appyapp

In my laravel app, I have two different types of users - customers, staff and both have different profile features.

I am thinking to create two separate tables - for example;

customer_profiles
user_id -> foreign key to users
company_name
etc 
etc

staff_profiles
user_id -> foreign key to users
notice_period
etc
etc

I don't think I need to have an auto increment on these tables?

My questions are:

Is it going to be a hasOne() relationship in users table? e.g.

public function staffProfile() 
{
   return $this->hasOne('App/StaffProfile');
}
public function customerProfile() 
{
   return $this->hasOne('App/CustomerProfile');
}

When any of these users login and if they haven't completed their profile, I want to prompt them to complete their profile before they can do any thing else. How do I do that?

Please sign in or create an account to participate in this conversation.