-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Associate a single role to multi-structures #1654
Comments
This package implements polymorphic relations between its model-has-roles/model-has-permissions tables and your application's "user" models. Your "user" models could be any models that implement the necessary contracts and traits. Often people equate "profiles" with Roles, where a predefined group of permissions is granted. I'm not sure what you mean by "structure" in your case. If it's multi-tenancy, it's quite easy to associate users with their own roles/permissions within separate databases for each tenant. Slightly more complex for a single-database multitenancy setup. What do you mean by "structure" and "profile"? Real-world examples? |
No it's not multi-tenant. For example, by structure I mean an organization. That is, a company has multiple organizations within it. The organizations are associated with the users and therefore for each of this user it has a role with different permissions. |
How are the different organizations distinguished/separated from each other? Just an id associated with a certain table? polymorphic models? Is there a one-to-many relationship between a User and an Organization? If this exists then you can extend the package to accommodate these relationships unique to your app. How are users identified as being in control of features related to a certain organization? Do they login to (and have access to only) one org at a time vs to another org via a certain Guard? If it's guard-based, you can define roles associated to certain guards. |
I have an organization_user table where for each user I assign the various organizations. organizations have a unique code that identifies them. Once the user logs in, he finds a screen where he has to choose the organization with which to log in. |
Simplest would be to name your roles, and maybe permissions too, with an organization prefix (probably associate them with defined ENUMs in your application), and use those everywhere you refer to a role/permission in app code. Or, you could add more fields to the schema and extend the package to add additional relational lookup/pairing to specific organizations. Or, you could explore "never granting Users anything" (User model), but instead only granting "organization_users", if that's a Model in your app. |
I cannot create a prefix for each organization as it can be hundreds. At this point I add a column in model_has_roles and model_has_permission ditto for the permissions associated directly with the user. Correct? when I call, for example, $user->hasRole('role') how can I tell him that that structure must verify it? |
This 3-way pivot you're working on is not something this package does directly. As you can see, it requires you to extend the package to add all of those additional relations and logic, specific to your chosen app implementation. Things to consider, in no particular order:
|
Ok all very clear, now I reflect on which path to take. Thank you so much. |
Solution I copied and pasted in the User model the basic functions from
and i added the My User model:
In the permission migration i added the column |
Dear contributor, because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it. |
Hi I am working with same type of functionality added company_id in modal_has_role and modal_has_permission table I override following functions in my User modal
It's cheking fine but not able to insert company_id which are in session how I can do it please help. |
Hi,
i need to associate the user with more structures, and the user role are different for every structures.
Example:
USER A => associated to Structure N.1 with profile X,
USER A => associated to Structure N.2 with profile Y,
how can I associate the different profile for each structure?
Thanks,
Andrea.
The text was updated successfully, but these errors were encountered: