protected function extractChildRelations(array $relations, string $identifier): array
    {
        return array_reduce(array_keys($relations), function ($nested, $relation) use ($relations, $identifier) {
            if (! starts_with($relation, "$identifier.")) {
                return $nested;
            }

            $nestedIdentifier = explode('.', $relation);
            array_shift($nestedIdentifier);

            return array_merge($nested, [implode('.', $nestedIdentifier) => $relations[$relation]]);
        }, []);
    }
protected function extractChildRelations(array $relations, string $identifier): array
    {
        return array_reduce(array_keys($relations), function ($nested, $relation) use ($relations, $identifier) {
            if (! starts_with($relation, "$identifier.")) {
                return $nested;
            }

            $nestedIdentifier = explode('.', $relation);
            array_shift($nestedIdentifier);

            return array_merge($nested, [implode('.', $nestedIdentifier) => $relations[$relation]]);
        }, []);
    }
protected function extractChildRelations ( array $ relations , string $ identifier ) : array { return array_reduce ( array_keys ( $ relations ) , function ( $ nested , $ relation ) use ( $ relations , $ identifier ) { if ( ! starts_with ( $ relation , "$identifier." ) ) { return $ nested ; } $ nestedIdentifier = explode ( '.' , $ relation ) ; array_shift ( $ nestedIdentifier ) ; return array_merge ( $ nested , [ implode ( '.' , $ nestedIdentifier ) => $ relations [ $ relation ] ] ) ; } , [ ] ) ; }
Extract all nested relations under a given identifier.

@param  array  $relations
@param  string $identifier
@return array
Extract all nested relations under a given identifier .