protected function addMissingParentRelations(array $relations)
    {

        $filled = $relations;

        foreach ($relations as $relation) {

            $segments = explode('.', $relation);
            $path = [];
            foreach ($segments as $segment) {
                $path[] = $segment;
                $pathString = implode('.', $path);
                if (!in_array($pathString, $relations)) {
                    $filled[] = $pathString;
                }
            }
        }

        return $filled;

    }
protected function addMissingParentRelations(array $relations)
    {

        $filled = $relations;

        foreach ($relations as $relation) {

            $segments = explode('.', $relation);
            $path = [];
            foreach ($segments as $segment) {
                $path[] = $segment;
                $pathString = implode('.', $path);
                if (!in_array($pathString, $relations)) {
                    $filled[] = $pathString;
                }
            }
        }

        return $filled;

    }
protected function addMissingParentRelations ( array $ relations ) { $ filled = $ relations ; foreach ( $ relations as $ relation ) { $ segments = explode ( '.' , $ relation ) ; $ path = [ ] ; foreach ( $ segments as $ segment ) { $ path [ ] = $ segment ; $ pathString = implode ( '.' , $ path ) ; if ( ! in_array ( $ pathString , $ relations ) ) { $ filled [ ] = $ pathString ; } } } return $ filled ; }
If you pass a relation filter of only address.country.territory
this method adds the not passed address and address.country relations.

@param array $relations

@return array
If you pass a relation filter of only address . country . territory this method adds the not passed address and address . country relations .