Hello, I'm new to Laravel and still have a lot to learn. I need some advice about user role on a project I'm working on.
I have a Distributor model and 2 user roles: Admin and Manager. The requirements are as follow:
User can be an Admin on 1 Distributor. Can create, update, delete.
User can be a Manager on several Distributors. Can view the combined summary of all Distributors they are on.
User can be an Admin and Manager at the same time (ex: Admin on Distributor A + Manager on Distributor A and Distributor B).
In short, a User can have different roles on several Distributors. Now I'm not sure how to implement the User-Role-Distributor relationship.
I'm using Sentinel and doing fine with 1 Distributor, but have no idea what to do next.
Or should I restrict the requirements so that a User can only have 1 role (Admin OR Manager)? That way I can add User-Distributor relationship to manage permissions. My only concern is that a person might need 2 account and juggling between them to get different access/permission.
I would probably have two separate 'pivot' tables one would be admins and one managers
In each have a distributor_id and user_id column
You can then allocate one or more admins to a distributor, and one or more managers.
Its then fairly easy to check if the user is mentioned in the admin table for a specific distributor, or finding all the distributors for which the user is a manager
You could do it with a single table and an additional type column but this seems to unnecessarily complicate matters.