src/ConcatenatesRelationships.php
protected function hasOneOrManyDeepFromMorphToMany(MorphToMany $relation, array $through, array $foreignKeys, array $localKeys)
    {
        $through[] = $relation->getTable();

        if ($relation->getInverse()) {
            $foreignKeys[] = $relation->getForeignPivotKeyName();
            $foreignKeys[] = $relation->getRelatedKeyName();

            $localKeys[] = $relation->getParentKeyName();
            $localKeys[] = [$relation->getMorphType(), $relation->getRelatedPivotKeyName()];
        } else {
            $foreignKeys[] = [$relation->getMorphType(), $relation->getForeignPivotKeyName()];
            $foreignKeys[] = $relation->getRelatedKeyName();

            $localKeys[] = $relation->getParentKeyName();
            $localKeys[] = $relation->getRelatedPivotKeyName();
        }

        return [$through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromMorphToMany(MorphToMany $relation, array $through, array $foreignKeys, array $localKeys)
    {
        $through[] = $relation->getTable();

        if ($relation->getInverse()) {
            $foreignKeys[] = $relation->getForeignPivotKeyName();
            $foreignKeys[] = $relation->getRelatedKeyName();

            $localKeys[] = $relation->getParentKeyName();
            $localKeys[] = [$relation->getMorphType(), $relation->getRelatedPivotKeyName()];
        } else {
            $foreignKeys[] = [$relation->getMorphType(), $relation->getForeignPivotKeyName()];
            $foreignKeys[] = $relation->getRelatedKeyName();

            $localKeys[] = $relation->getParentKeyName();
            $localKeys[] = $relation->getRelatedPivotKeyName();
        }

        return [$through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromMorphToMany ( MorphToMany $ relation , array $ through , array $ foreignKeys , array $ localKeys ) { $ through [ ] = $ relation -> getTable ( ) ; if ( $ relation -> getInverse ( ) ) { $ foreignKeys [ ] = $ relation -> getForeignPivotKeyName ( ) ; $ foreignKeys [ ] = $ relation -> getRelatedKeyName ( ) ; $ localKeys [ ] = $ relation -> getParentKeyName ( ) ; $ localKeys [ ] = [ $ relation -> getMorphType ( ) , $ relation -> getRelatedPivotKeyName ( ) ] ; } else { $ foreignKeys [ ] = [ $ relation -> getMorphType ( ) , $ relation -> getForeignPivotKeyName ( ) ] ; $ foreignKeys [ ] = $ relation -> getRelatedKeyName ( ) ; $ localKeys [ ] = $ relation -> getParentKeyName ( ) ; $ localKeys [ ] = $ relation -> getRelatedPivotKeyName ( ) ; } return [ $ through , $ foreignKeys , $ localKeys ] ; }
Prepare a has-one-deep or has-many-deep relationship from an existing morph-to-many relationship.

@param  \Illuminate\Database\Eloquent\Relations\MorphToMany  $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 morph - to - many relationship .