Hello,
I don't want to use the Spatie package for the roles, I prefer to manage them myself.
Here is the context : several companies can connect to the app and manage their own data and their own collaborators who can access to the datas of their company. I thought about setting up a multitenancy app, but I'm not sure I really need it and you discouraged me to do that unless I have good knowledge about multitenancy --- and I don't have ---.
So I have created those two tables (I don't have any roles table, the roles are written in a configuration file).
members : id, company_id, user_id
roles : member_id, role_id
Here is my two questions.
- I realize that this is heavy to manage and I want to change it to one unique table where the
roles field is an array containing the roles ids.
// Choice A
members: id, company_id, user_id, roles
Another way would have been this one where the superadmin, admin, manager, ... fields are booleans.
// Choice B
members: id, company_id, user_id, superadmin, admin, manager, trainer, student
What do you think about ? What would you suggest me ? I know that if I need to query for all students of a company, choice B will be better because otherwise I will need to filter through the array field values, but with choice B I will have less flexibility if I need to add a new role for example.
- For these roles, if I choose choice A, I have two possibilities : 0, 1, 2, 3, ... (roles numbers are in the configuration file) of directly write strings in the array (SUPERADMIN, ADMIN, MANAGER, TRAINER, STUDENT, ...).
Is there a best choice between number and strings ?
Thanks for your help.
Vincent