src/ConcatenatesRelationships.php
protected function hasOneOrManyDeepFromHasManyDeep(HasManyDeep $relation, array $through, array $foreignKeys, array $localKeys)
    {
        foreach ($relation->getThroughParents() as $throughParent) {
            $segments = explode(' as ', $throughParent->getTable());

            $class = get_class($throughParent);

            if (isset($segments[1])) {
                $class .= ' as '.$segments[1];
            } elseif ($throughParent instanceof Pivot) {
                $class = $throughParent->getTable();
            }

            $through[] = $class;
        }

        $foreignKeys = array_merge($foreignKeys, $relation->getForeignKeys());

        $localKeys = array_merge($localKeys, $relation->getLocalKeys());

        return [$through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromHasManyDeep(HasManyDeep $relation, array $through, array $foreignKeys, array $localKeys)
    {
        foreach ($relation->getThroughParents() as $throughParent) {
            $segments = explode(' as ', $throughParent->getTable());

            $class = get_class($throughParent);

            if (isset($segments[1])) {
                $class .= ' as '.$segments[1];
            } elseif ($throughParent instanceof Pivot) {
                $class = $throughParent->getTable();
            }

            $through[] = $class;
        }

        $foreignKeys = array_merge($foreignKeys, $relation->getForeignKeys());

        $localKeys = array_merge($localKeys, $relation->getLocalKeys());

        return [$through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromHasManyDeep ( HasManyDeep $ relation , array $ through , array $ foreignKeys , array $ localKeys ) { foreach ( $ relation -> getThroughParents ( ) as $ throughParent ) { $ segments = explode ( ' as ' , $ throughParent -> getTable ( ) ) ; $ class = get_class ( $ throughParent ) ; if ( isset ( $ segments [ 1 ] ) ) { $ class .= ' as ' . $ segments [ 1 ] ; } elseif ( $ throughParent instanceof Pivot ) { $ class = $ throughParent -> getTable ( ) ; } $ through [ ] = $ class ; } $ foreignKeys = array_merge ( $ foreignKeys , $ relation -> getForeignKeys ( ) ) ; $ localKeys = array_merge ( $ localKeys , $ relation -> getLocalKeys ( ) ) ; return [ $ through , $ foreignKeys , $ localKeys ] ; }
Prepare a has-one-deep or has-many-deep relationship from an existing has-many-deep relationship.

@param  \Staudenmeir\EloquentHasManyDeep\HasManyDeep  $relation
@param  \Illuminate\Database\Eloquent\Model[]  $through
@param  array  $foreignKeys
@param  array  $localKeys
@return array
Prepare a has - one - deep or has - many - deep relationship from an existing has - many - deep relationship .