public function relation(string $resource, int $version = null) : ResourceDefinition
    {
        $version = $version ?? $this->version;

        $found = $this->relations->filter(function (ResourceDefinition $definition) use ($resource, $version) {
            return $definition->version === $version && $definition->resource === $resource;
        });

        if ($found->isEmpty()) {
            throw ResourceNotDefinedException::resource($resource, 'version ' . $version);
        }

        return $found->first();
    }
public function relation(string $resource, int $version = null) : ResourceDefinition
    {
        $version = $version ?? $this->version;

        $found = $this->relations->filter(function (ResourceDefinition $definition) use ($resource, $version) {
            return $definition->version === $version && $definition->resource === $resource;
        });

        if ($found->isEmpty()) {
            throw ResourceNotDefinedException::resource($resource, 'version ' . $version);
        }

        return $found->first();
    }
public function relation ( string $ resource , int $ version = null ) : ResourceDefinition { $ version = $ version ?? $ this -> version ; $ found = $ this -> relations -> filter ( function ( ResourceDefinition $ definition ) use ( $ resource , $ version ) { return $ definition -> version === $ version && $ definition -> resource === $ resource ; } ) ; if ( $ found -> isEmpty ( ) ) { throw ResourceNotDefinedException :: resource ( $ resource , 'version ' . $ version ) ; } return $ found -> first ( ) ; }
returns relation by resource and version

@param string $resource
@param int|null $version
@return ResourceDefinition
returns relation by resource and version