romanbican / roles

Powerful package for handling roles and permissions in Laravel 5
MIT License
1.16k stars 297 forks source link

Use logic operators instead of dual methods #211

Open wffranco opened 7 years ago

wffranco commented 7 years ago

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