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

syntaxerron's avatar

Users with different User Types

I have a Laravel application to build that has 3 user types: employee, admin, customer. Each user type has different access to different parts of the application.

I have 3 approaches and I am confused which would be better and have lesser complications on querying the results. The admin user is an employee with administrative privileges. The employee and customer have both common fields (e.g. first_name, last_name, gender) and unique fields (e.g. job_title and department_id for employee only)

1st approach: store all information in the users table (separated by user_type field) with fields like department_id and job_title set to nullable.

2nd approach: create individual tables (employees, customers) and link each to users table with a one-to-one relationship

3rd approach: create a contacts table to store employee/customer information and link to users table with a one-to-one relationship and with fields department_id and job_title set to nullable.

In addition, each user type can have different permissions. Example: An employee can add, edit and view data while other employees can only add and view the data. I am trying the permission package from spatie to handle these actions.

0 likes
4 replies
talel's avatar

Hey @loose1eaf, Looks like the second option presented by you make the most sense.

By following the second option you can avoid have many database records which are customer with an empty job_title and empty department_id for no good reason. It is best to create a record in a separate table and link them to a user, which can help you minimize the number of empty fields in your database in the first place.

All of the entities in your application are users and should be store in the user table, for each user who happened to be a customer,employee, or an admin you can create a separate record and tie those records together. As you mentioned, with a simple roles and privileges structure you can manage the privileges of your employee & admin users. The Laravel-permission package from spatie together with laravel Policies should work perfectly.

Good luck!

1 like
syntaxerron's avatar

Thank you. Just a thought, what if an employee is also a customer? Do I have to add his information separately on the customers table?

grunburg's avatar

I suggest getting into roles (admin,employee,costumer) and permissions and would think of the structure like this:

admin
└── employee
    └── costumer

For example you can add that admin can do the same things as employee and costumer, and employee can do the same stuff as costumer but has no access to admin things, the same with costumer

Snapey's avatar

They would have the employee role AND the customer role (not a hierarchy)

What they can do is the combined permissions from both roles. Note that Spatie permissions are always adding ability, not taking away ability.

Please or to participate in this conversation.