Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

Conversation

@wffranco
Copy link

Instead of using mutable functions (one / all) the best solution is to use logical operators ( & | ).
That way we get an extra function mixing both... can do things like that:

if (Auth::user()->hasRole('admin|employee&manager|employee&advanced')) {
    //do something if:
    //- user is admin
    //- user is an employee manager
    //- user is an employee with advanced role
}

Like in normal coding, the and operator has priority.

Removed: getMethodName, getArrayFrom
Included: matchOperator, mapOrAnd

Instead of using mutable functions (one / all) the best solution is to use logical operators ( & | ).
That way we get an extra function mixing both... can do things like that:
```php
if (Auth::user()->hasRole('admin|employee&manager|employee&advanced')) {
    //do something if:
    //- user is admin
    //- user is an employee manager
    //- user is an employee with advanced role
}
```
Like in normal coding, the and operator has priority.

Removed: getMethodName, getArrayFrom
Included: matchOperator, mapOrAnd
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant