src/ConcatenatesRelationships.php
protected function hasOneOrManyDeepFromRelations(array $relations)
    {
        if (is_array($relations[0])) {
            $relations = $relations[0];
        }

        $related = null;
        $through = [];
        $foreignKeys = [];
        $localKeys = [];

        foreach ($relations as $i => $relation) {
            $method = $this->hasOneOrManyDeepRelationMethod($relation);

            [$through, $foreignKeys, $localKeys] = $this->$method($relation, $through, $foreignKeys, $localKeys);

            if ($i === count($relations) - 1) {
                $related = get_class($relation->getRelated());
            } else {
                $through[] = get_class($relation->getRelated());
            }
        }

        return [$related, $through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromRelations(array $relations)
    {
        if (is_array($relations[0])) {
            $relations = $relations[0];
        }

        $related = null;
        $through = [];
        $foreignKeys = [];
        $localKeys = [];

        foreach ($relations as $i => $relation) {
            $method = $this->hasOneOrManyDeepRelationMethod($relation);

            [$through, $foreignKeys, $localKeys] = $this->$method($relation, $through, $foreignKeys, $localKeys);

            if ($i === count($relations) - 1) {
                $related = get_class($relation->getRelated());
            } else {
                $through[] = get_class($relation->getRelated());
            }
        }

        return [$related, $through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromRelations ( array $ relations ) { if ( is_array ( $ relations [ 0 ] ) ) { $ relations = $ relations [ 0 ] ; } $ related = null ; $ through = [ ] ; $ foreignKeys = [ ] ; $ localKeys = [ ] ; foreach ( $ relations as $ i => $ relation ) { $ method = $ this -> hasOneOrManyDeepRelationMethod ( $ relation ) ; [ $ through , $ foreignKeys , $ localKeys ] = $ this -> $ method ( $ relation , $ through , $ foreignKeys , $ localKeys ) ; if ( $ i === count ( $ relations ) - 1 ) { $ related = get_class ( $ relation -> getRelated ( ) ) ; } else { $ through [ ] = get_class ( $ relation -> getRelated ( ) ) ; } } return [ $ related , $ through , $ foreignKeys , $ localKeys ] ; }
Prepare a has-one-deep or has-many-deep relationship from existing relationships.

@param  \Illuminate\Database\Eloquent\Relations\Relation[]  $relations
@return array
Prepare a has - one - deep or has - many - deep relationship from existing relationships .