protected function getAuthorizedResources($methods = null)
    {
        $resources = [];

        if ($this->auth instanceof Authentication) {
            $allow = (array) ($methods ?? $this->method);

            $authorizations = Authorization::dump(
                [
                    'user' => $this->auth->id,
                ],
                [
                    'resource',
                    'methods',
                    'filter',
                ]
            );

            foreach ($authorizations as $authorization) {
                $resource = $authorization['resource'];
                if (array_key_exists($resource, $this->resources)) {
                    if ($this->isPublic($resource, $methods)) {
                        $resources[$resource] = null;
                    } elseif (!empty(array_intersect(
                        $this->getAllowedMethods($resource),
                        array_merge(
                            $authorization['methods'] ?? [],
                            $allow
                        )
                    ))) {
                        $resources[$resource] = $authorization['filter'];
                    }
                }
            }
        } else {
            $resources = array_keys($this->resources);

            if ($this->auth === false) {
                foreach ($resources as $id => $resource) {
                    if (!$this->isPublic($resource, $methods)) {
                        unset($resources[$id]);
                    }
                }
            }

            $resources = array_fill_keys(array_values($resources), null);
        }

        return $resources;
    }
protected function getAuthorizedResources($methods = null)
    {
        $resources = [];

        if ($this->auth instanceof Authentication) {
            $allow = (array) ($methods ?? $this->method);

            $authorizations = Authorization::dump(
                [
                    'user' => $this->auth->id,
                ],
                [
                    'resource',
                    'methods',
                    'filter',
                ]
            );

            foreach ($authorizations as $authorization) {
                $resource = $authorization['resource'];
                if (array_key_exists($resource, $this->resources)) {
                    if ($this->isPublic($resource, $methods)) {
                        $resources[$resource] = null;
                    } elseif (!empty(array_intersect(
                        $this->getAllowedMethods($resource),
                        array_merge(
                            $authorization['methods'] ?? [],
                            $allow
                        )
                    ))) {
                        $resources[$resource] = $authorization['filter'];
                    }
                }
            }
        } else {
            $resources = array_keys($this->resources);

            if ($this->auth === false) {
                foreach ($resources as $id => $resource) {
                    if (!$this->isPublic($resource, $methods)) {
                        unset($resources[$id]);
                    }
                }
            }

            $resources = array_fill_keys(array_values($resources), null);
        }

        return $resources;
    }
protected function getAuthorizedResources ( $ methods = null ) { $ resources = [ ] ; if ( $ this -> auth instanceof Authentication ) { $ allow = ( array ) ( $ methods ?? $ this -> method ) ; $ authorizations = Authorization :: dump ( [ 'user' => $ this -> auth -> id , ] , [ 'resource' , 'methods' , 'filter' , ] ) ; foreach ( $ authorizations as $ authorization ) { $ resource = $ authorization [ 'resource' ] ; if ( array_key_exists ( $ resource , $ this -> resources ) ) { if ( $ this -> isPublic ( $ resource , $ methods ) ) { $ resources [ $ resource ] = null ; } elseif ( ! empty ( array_intersect ( $ this -> getAllowedMethods ( $ resource ) , array_merge ( $ authorization [ 'methods' ] ?? [ ] , $ allow ) ) ) ) { $ resources [ $ resource ] = $ authorization [ 'filter' ] ; } } } } else { $ resources = array_keys ( $ this -> resources ) ; if ( $ this -> auth === false ) { foreach ( $ resources as $ id => $ resource ) { if ( ! $ this -> isPublic ( $ resource , $ methods ) ) { unset ( $ resources [ $ id ] ) ; } } } $ resources = array_fill_keys ( array_values ( $ resources ) , null ) ; } return $ resources ; }
Returns authorized resources for the authenticated user and their filters

@param string|string[] $methods Which methods to test
Default is requested method

@return mixed[] With 'resource' => filter
Returns authorized resources for the authenticated user and their filters