app\Models\Access\User\Traits\UserAccess::hasRole PHP Method

hasRole() public method

Checks if the user has a Role by its name or id.
public hasRole ( string $nameOrId ) : boolean
$nameOrId string Role name or id.
return boolean
    public function hasRole($nameOrId)
    {
        foreach ($this->roles as $role) {
            //See if role has all permissions
            if ($role->all) {
                return true;
            }
            //First check to see if it's an ID
            if (is_numeric($nameOrId)) {
                if ($role->id == $nameOrId) {
                    return true;
                }
            }
            //Otherwise check by name
            if ($role->name == $nameOrId) {
                return true;
            }
        }
        return false;
    }