Skip to content
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

Strict typing on Role Contract prevents looking Role up by UUID #1561

Closed
kylelogue opened this issue Sep 7, 2020 · 2 comments · Fixed by #2089
Closed

Strict typing on Role Contract prevents looking Role up by UUID #1561

kylelogue opened this issue Sep 7, 2020 · 2 comments · Fixed by #2089

Comments

@kylelogue
Copy link

https://github.com/spatie/laravel-permission/blob/master/src/Contracts/Role.php#L38

this is forcing the $id to be an int, and when you swap to UUIDs this function is no longer usable. You can't even replace the implementation bc that would have to implement this contract as well

throws error:

Argument 1 passed to Spatie\\Permission\\Models\\Role::findById() must be of the type int, string given
@drbyte
Copy link
Collaborator

drbyte commented Sep 8, 2020

There are a half-dozen places where this is used, and all of those only fall findById if the value is integer/numeric.
I assume your reason for posting is that you've removed those integer/numeric filters in your code?
Changing the integer/numeric filter to allow strings would get confused with actual named permissions/roles. Assuming the (int) contract were changed, how were you envisioning preventing this confusion of uuid strings with role/permission name strings?

@kylelogue
Copy link
Author

I ended up writing my own role/permission logic as what I needed wasn't supported by this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants