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

Use logic operators instead of dual methods #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Use logic operators instead of dual methods #211

wants to merge 1 commit into from

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