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

Test User has more than one roles ? #52

Closed
JFOC opened this issue Feb 26, 2016 · 3 comments
Closed

Test User has more than one roles ? #52

JFOC opened this issue Feb 26, 2016 · 3 comments

Comments

@JFOC
Copy link

JFOC commented Feb 26, 2016

How to test if user has one or more roles ?
Example:
There is 3 roles: admin, support, staff
User A is assigned for roles admin

If I want to know if user A has roles admin or staff.

Trying to use hasAnyRoles but no luck

Is this bug ?

When hasAnyRole('admin','staff') will return true
When hasAnyRole('staff','admin') will return false

Thanks

@arcanedev-maroc
Copy link

arcanedev-maroc commented Feb 26, 2016

The hasAnyRole() method except only string, Collection object or Role Model as $roles argument.

Is it a bug ? Yes.

You can check the source code https://github.com/spatie/laravel-permission/blob/master/src/Traits/HasRoles.php#L70.

@freekmurze
Copy link
Member

This is indeed a bug, and I'm working on a fix. Thanks for letting me know.

@freekmurze
Copy link
Member

Fixed in version 1.3.4

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

No branches or pull requests

3 participants