Closed chrispage1 closed 8 months ago
Hey @eneadm , just double checking you've seen this one? Thanks!
@chrispage1 Yep, I just was way too busy these days. I looks interesting but multi tenancy is not something I would like to add to the package for the moment. However what would be nice to have in the future is a Teams feature kinda similar to:
Teams cover the multi tenancy case but also other use-cases in one solution. I am currently working on this feature but it might be a while until I release it, also I don't want to enforce it on newcomers or existing users using this package.
Thank you very much for creating the PR though since any help will not go wasted and will definitely help me progress with the new feature.
This contribution fixes a requirement for one of our projects to have the ability to assign users different roles and permissions, depending on the current 'tenant' they are logged in as.
This PR adds functionality to the main Ladder static, allowing for global scoping which can quickly and easily be utilised for providers / middleware etc by calling
Ladder\Ladder::setTenant('the_tenant')
Or localised scoping by calling
$user->forTenant('tenant_name')->hasPermission('read')
.It achieves this by adding a
tenant
column to the database which can be a string, or integer, keeping it fairly open.The change is non breaking for existing installations and provides a pretty major enhancement and makes it more versatile.
In addition I've created a simple helper method called
assignRole
that'll allow a user to quickly and easily programatically assign roles. E.g.$user->assignRole('admin')
.