public function declareOneToManyRelationships($relationships)
    {
        if (!is_array($relationships)) {
            throw new RelationshipDefinitionException("DefineOneToManyRelationships must be passed an array");
        }

        foreach ($relationships as $oneModel => $definitions) {
            $oneModelColumnName = "";

            if (stripos($oneModel, ".") !== false) {
                $parts = explode(".", $oneModel);
                $oneModel = $parts[0];
                $oneModelColumnName = $parts[1];
            }

            foreach ($definitions as $oneNavigationName => $definition) {
                $parts = explode(".", $definition);

                $manyModelName = $parts[0];

                if (stripos($parts[1], ":") !== false) {
                    $subParts = explode(":", $parts[1]);

                    $manyColumnName = $subParts[0];
                    $manyNavigationName = $subParts[1];
                } else {
                    $manyColumnName = $parts[1];
                    $manyNavigationName = $oneModel;
                }

                $this->declareOneToManyRelationship(
                    $oneModel,
                    $oneModelColumnName,
                    $oneNavigationName,
                    $manyModelName,
                    $manyColumnName,
                    $manyNavigationName
                );
            }
        }
    }
public function declareOneToManyRelationships($relationships)
    {
        if (!is_array($relationships)) {
            throw new RelationshipDefinitionException("DefineOneToManyRelationships must be passed an array");
        }

        foreach ($relationships as $oneModel => $definitions) {
            $oneModelColumnName = "";

            if (stripos($oneModel, ".") !== false) {
                $parts = explode(".", $oneModel);
                $oneModel = $parts[0];
                $oneModelColumnName = $parts[1];
            }

            foreach ($definitions as $oneNavigationName => $definition) {
                $parts = explode(".", $definition);

                $manyModelName = $parts[0];

                if (stripos($parts[1], ":") !== false) {
                    $subParts = explode(":", $parts[1]);

                    $manyColumnName = $subParts[0];
                    $manyNavigationName = $subParts[1];
                } else {
                    $manyColumnName = $parts[1];
                    $manyNavigationName = $oneModel;
                }

                $this->declareOneToManyRelationship(
                    $oneModel,
                    $oneModelColumnName,
                    $oneNavigationName,
                    $manyModelName,
                    $manyColumnName,
                    $manyNavigationName
                );
            }
        }
    }
public function declareOneToManyRelationships ( $ relationships ) { if ( ! is_array ( $ relationships ) ) { throw new RelationshipDefinitionException ( "DefineOneToManyRelationships must be passed an array" ) ; } foreach ( $ relationships as $ oneModel => $ definitions ) { $ oneModelColumnName = "" ; if ( stripos ( $ oneModel , "." ) !== false ) { $ parts = explode ( "." , $ oneModel ) ; $ oneModel = $ parts [ 0 ] ; $ oneModelColumnName = $ parts [ 1 ] ; } foreach ( $ definitions as $ oneNavigationName => $ definition ) { $ parts = explode ( "." , $ definition ) ; $ manyModelName = $ parts [ 0 ] ; if ( stripos ( $ parts [ 1 ] , ":" ) !== false ) { $ subParts = explode ( ":" , $ parts [ 1 ] ) ; $ manyColumnName = $ subParts [ 0 ] ; $ manyNavigationName = $ subParts [ 1 ] ; } else { $ manyColumnName = $ parts [ 1 ] ; $ manyNavigationName = $ oneModel ; } $ this -> declareOneToManyRelationship ( $ oneModel , $ oneModelColumnName , $ oneNavigationName , $ manyModelName , $ manyColumnName , $ manyNavigationName ) ; } } }
Defines one or more one-to-many relationships in an array structure.

e.g.

$this->declareOneToManyRelationships(
[
"Customer" =>
[
"Orders" => "Order.CustomerID"
]
] );

@param  array $relationships
@throws \Rhubarb\Stem\Exceptions\RelationshipDefinitionException
Defines one or more one - to - many relationships in an array structure .