Has filter
@param string $permission Permission lookup key
@return boolean
9360
protected function hasFilter($permission)
    {
        if ($this->cacheHas($permission)
            && true === $this->cache($permission)
        ) {
            return true;
        }

        $permissionResult   =   $this->getPermission($permission);

        if ($permissionResult) {
            return $this->cache($permission, $permissionResult->isAllowed());
        }

        return $this->cache($permission, false);
    }
281138
public function hasPermission($permission)
    {
        if (!is_array($this->permissionsMap)) {
            $permissionsMap = cache()->get('permissions:' . $this->id, null);
            if ($permissionsMap === null) { // Not in cache
                $this->permissionsMap = $this->buildPermissionsMap();
                cache()->forever('permissions:' . $this->id, $this->permissionsMap);
            } else {
                $this->permissionsMap = $permissionsMap;
            }
        }
        return in_array($permission, $this->permissionsMap);
    }
597210
public function revokePermission($permission)
    {
        if ($this->hasPermission($permission)) {
            unset($this->permissions[$permission]);
            return true;
        } else {
            return false;
        }
    }
186763
public function hasPermission($permission)
    {
        foreach ($this->permissions()->get() as $p) {
            if ($p->name == $permission) {
                return true;
            }
        }
        return false;
    }
1343183
protected function hasPermissionThroughRole($permission): bool
    {
        foreach ($permission->roles as $role) {
            if ($this->roles->contains($role)) {
                return true;
            }
        }

        return false;
    }
100407
public function hasPermission($permissionName) {
		foreach ($this->role->sharedPermissionList as $permission) {
			if ($permission->name == $permissionName) {
				return true;
			}
		}

		return false;
	}
263987
public function hasDirectPermission($permission): bool
    {
        $permissionClass = $this->getPermissionClass();

        if (is_string($permission)) {
            $permission = $permissionClass->findByName($permission, $this->getDefaultGuardName());
            if (! $permission) {
                return false;
            }
        }

        if (is_int($permission)) {
            $permission = $permissionClass->findById($permission, $this->getDefaultGuardName());
            if (! $permission) {
                return false;
            }
        }

        if (! $permission instanceof Permission) {
            return false;
        }

        return $this->permissions->contains('id', $permission->id);
    }
14896
public function hasPermissionThroughRole($permission)
    {
        if (! $this->isMethodRolesExists()) {
            return false;
        }

        if (! $permission = $this->preparePermission($permission)) {
            return false;   
        }

        foreach ($permission->roles as $role) { 
            if ($this->roles->contains($role)) {
                return true;
            }
        }

        return false;
    }
110256
public function can($permission, $requireAll = false)
    {
        if (is_array($permission)) {
            foreach ($permission as $permName) {
                $hasPerm = $this->can($permName);

                if ($hasPerm && !$requireAll) {
                    return true;
                } elseif (!$hasPerm && $requireAll) {
                    return false;
                }
            }

            // If we've made it this far and $requireAll is FALSE, then NONE of the perms were found
            // If we've made it this far and $requireAll is TRUE, then ALL of the perms were found.
            // Return the value of $requireAll;
            return $requireAll;
        } else {
            foreach ($this->cachedRoles() as $role) {
                // Validate against the Permission table
                foreach ($role->cachedPermissions() as $perm) {
                    if (str_is( $permission, $perm->name) ) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
333408
public function removePermission($permission)
    {
        if ($this->hasPermission($permission)) {
            $index =  array_search($permission, $this->permissions);
            unset($this->permissions[$index]);
        }

        return $this;
    }
1327200
public static function check($permission)
    {
        if (static::isAdministrator()) {
            return true;
        }

        if (is_array($permission)) {
            collect($permission)->each(function ($permission) {
                call_user_func([Permission::class, 'check'], $permission);
            });

            return;
        }

        if (Auth::guard('merchant')->user()->cannot($permission)) {
            static::error();
        }
    }
1285633
public function currentRoleHasPermission($permission, $requireAll = false)
    {
        if (empty($permission)) {
            return true;
        }

        $permission = Helper::standardize($permission);
        $permissionsNames = is_array($permission) ? $permission : [$permission];

        list($permissionsWildcard, $permissionsNoWildcard) =
            Helper::getPermissionWithAndWithoutWildcards($permissionsNames);

        $permissionsCount = $this->role->permissions()
            ->whereIn('name', $permissionsNoWildcard)
            ->when($permissionsWildcard, function ($query) use ($permissionsWildcard) {
                foreach ($permissionsWildcard as $permission) {
                    $query->orWhere('name', 'like', $permission);
                }

                return $query;
            })
            ->count();

        return $requireAll
            ? $permissionsCount >= count($permissionsNames)
            : $permissionsCount > 0;
    }
337805
public function permission($permission): bool
    {
        $perms = fileperms($this->getAbsoluteFilePath());

        switch ($permission) {
            case FilePermission::READ_OWNER:
                return (($perms & 0x0100) ? true : false);

            case FilePermission::WRITE_OWNER:
                return (($perms & 0x0080) ? true : false);

            case FilePermission::EXE_OWNER:
                return (($perms & 0x0040) ?
                    (($perms & 0x0800) ? null /* 's' */ : true) :
                    (($perms & 0x0800) ? null /* 'S' */ : false));

            case FilePermission::READ_USER:
                return $this->isReadable();

            case FilePermission::WRITE_USER:
                return $this->isWritable();

            case FilePermission::EXE_USER:
                return $this->isExecutable();

            case FilePermission::READ_GROUP:
                return (($perms & 0x0020) ? true : false);

            case FilePermission::WRITE_GROUP:
                return (($perms & 0x0010) ? true : false);

            case FilePermission::EXE_GROUP:
                return (($perms & 0x0008) ?
                    (($perms & 0x0400) ? null /* 's' */ : true) :
                    (($perms & 0x0400) ? null /* 'S' */ : false));

            case FilePermission::READ_OTHER:
                return (($perms & 0x0004) ? true : false);

            case FilePermission::WRITE_OTHER:
                return (($perms & 0x0002) ? true : false);

            case FilePermission::EXE_OTHER:
                return (($perms & 0x0001) ?
                    (($perms & 0x0200) ? null /* 't' */ : true) :
                    (($perms & 0x0200) ? null /* 'T' */ : false));
        }

        return true;
    }
342123
public function has($permissions, $all = true)
    {
        if (! is_array($permissions)) {
            $permissions    =   (array) $permissions;
        }

        $permissions=   array_unique($permissions);
        $filtered   =   [];
        $usersRoles =   $this->roles;
        $allowed    =   false;
        $filtered   =   array_where($permissions, [$this, 'permissionFilter']);
        $filteredCount  =   count($filtered);

        // Does the permission lookup require all permissions to be found?
        if (true === $all) {
            return count($permissions) === $filteredCount;
        }

        // Nope, just as long as they have one of them
        return 0 < $filteredCount;
    }
309440
public function findWithoutPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($role) use ($permission) {
                return $role->hasnt($permission);
            }
        );
    }
1372939
public function isAllowed($permission = null, $role = null)
    {
        if ($permission && strpos($permission, '/') !== false) {
            list($controllerClassName, $action) = $this->inferControllerAction($permission);
            $controllerClassName = $this->alias->resolveNS($controllerClassName);
            if (!isset($this->_acl[$controllerClassName])) {
                /** @var \ManaPHP\Rest\Controller $controllerInstance */
                $controllerInstance = new $controllerClassName;
                $this->_acl[$controllerClassName] = $controllerInstance->getAcl();
            }
        } else {
            $controllerInstance = $this->dispatcher->getControllerInstance();
            $controllerClassName = get_class($controllerInstance);
            $action = $permission ? lcfirst(Text::camelize($permission)) : $this->dispatcher->getAction();

            if (!isset($this->_acl[$controllerClassName])) {
                $this->_acl[$controllerClassName] = $controllerInstance->getAcl();
            }
        }

        $acl = $this->_acl[$controllerClassName];

        $role = $role ?: $this->identity->getRole();
        if (strpos($role, ',') === false) {
            return $this->isAclAllow($acl, $role, $action);
        } else {
            foreach (explode($role, ',') as $r) {
                if ($this->isAclAllow($acl, $r, $action)) {
                    return true;
                }
            }

            return false;
        }
    }
196638
public function matchesPermission(Permission $permission)
    {
        return (
            $this instanceof $permission &&
            $this->action === $permission->getAction() && // Not using matchesAction to avoid the wildcard
            $this->matchesResource($permission->getResource())
        );
    }