Do you put multiple users in the `users` table or create separate tables for each of them `customer` and`admin`
I have been contemplating about this issue for a while. Please I want to know if you are asked to create multiple users for the app where customers, admins, and auditors will be using it, will you create separate tables for them or you you will create a single table and assign roles and permissions ?
Personally I would implement roles and put all users in one place. If I wanted to extend their data I would go for users_customer_data table or so with customer details. You could join by user_id.
class User extends Model
{
public function customerDetails()
{
return $this->hasOne(CustomerDetails::class, 'user_id');
}
}
class CustomerDetails extends Model
{
protected $table = 'users_customer';
protected $fillable = ['user_id', 'address', 'zip_code'];
}
$user = User::find(1);
//Of course you should handle these user types by yourself
if ($user->isCustomer()) {
echo $customer->customerDetails->address;
}