protected function hasOneOrManyDeepFromBelongsToMany(BelongsToMany $relation, array $through, array $foreignKeys, array $localKeys)
    {
        $through[] = $relation->getTable();

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

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

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

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

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

        return [$through, $foreignKeys, $localKeys];
    }
protected function hasOneOrManyDeepFromBelongsToMany ( BelongsToMany $ relation , array $ through , array $ foreignKeys , array $ localKeys ) { $ through [ ] = $ relation -> getTable ( ) ; $ foreignKeys [ ] = $ 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 belongs-to-many relationship.

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