-
-
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
Adds setRoleClass method to PermissionRegistrar #1867
Adds setRoleClass method to PermissionRegistrar #1867
Conversation
You have to keep in mind that this package uses cache and preload models in memory, and if you are going to change the models in the runtime(after cache load), maybe you could have unexpected failures because models from cache will be default ones(is what I understood in #1864), maybe you could add some test to check that |
Would duplicating the existing |
I think these tests are unnecessary, because they check the same as existing tests Maybe you do not need a test because it is possible that only you need that method |
I don't mean duplicating the existing
|
@drbyte also maybe better use Spatie\Permission\Contracts\Permission;
use Spatie\Permission\Contracts\Role; public function setPermissionClass($permissionClass)
{
$this->permissionClass = $permissionClass;
config()->set('permission.models.role', $permissionClass);
app()->bind(Permission::class, $permissionClass);
return $this;
}
public function setRoleClass($roleClass)
{
$this->roleClass = $roleClass;
config()->set('permission.models.role', $roleClass);
app()->bind(Role::class, $roleClass);
return $this;
} |
Sorry, I pushed that to my branch just to save my work, I wasn't finished yet. I will read over the rest of the replies and fix it up. |
eb615cc
to
be6d9b2
Compare
@erikn69 Do I need to make anymore modifications to this? |
I'm just trying to help, you have to wait for a collaborator to review the pr, they haven't connected lately |
Thanks! |
Issue #1864
Adding this to allow configuration of Role model class from a package's service provider.