src/HasManyDeep.php
protected function joinThroughParent(Builder $query, Model $throughParent, Model $predecessor, $foreignKey, $localKey, $prefix)
    {
        if (is_array($localKey)) {
            $query->where($throughParent->qualifyColumn($localKey[0]), '=', $predecessor->getMorphClass());

            $localKey = $localKey[1];
        }

        $first = $throughParent->qualifyColumn($localKey);

        if (is_array($foreignKey)) {
            $query->where($predecessor->qualifyColumn($foreignKey[0]), '=', $throughParent->getMorphClass());

            $foreignKey = $foreignKey[1];
        }

        $second = $predecessor->qualifyColumn($prefix.$foreignKey);

        $query->join($throughParent->getTable(), $first, '=', $second);

        if ($this->throughParentInstanceSoftDeletes($throughParent)) {
            $query->whereNull($throughParent->getQualifiedDeletedAtColumn());
        }
    }
protected function joinThroughParent(Builder $query, Model $throughParent, Model $predecessor, $foreignKey, $localKey, $prefix)
    {
        if (is_array($localKey)) {
            $query->where($throughParent->qualifyColumn($localKey[0]), '=', $predecessor->getMorphClass());

            $localKey = $localKey[1];
        }

        $first = $throughParent->qualifyColumn($localKey);

        if (is_array($foreignKey)) {
            $query->where($predecessor->qualifyColumn($foreignKey[0]), '=', $throughParent->getMorphClass());

            $foreignKey = $foreignKey[1];
        }

        $second = $predecessor->qualifyColumn($prefix.$foreignKey);

        $query->join($throughParent->getTable(), $first, '=', $second);

        if ($this->throughParentInstanceSoftDeletes($throughParent)) {
            $query->whereNull($throughParent->getQualifiedDeletedAtColumn());
        }
    }
protected function joinThroughParent ( Builder $ query , Model $ throughParent , Model $ predecessor , $ foreignKey , $ localKey , $ prefix ) { if ( is_array ( $ localKey ) ) { $ query -> where ( $ throughParent -> qualifyColumn ( $ localKey [ 0 ] ) , '=' , $ predecessor -> getMorphClass ( ) ) ; $ localKey = $ localKey [ 1 ] ; } $ first = $ throughParent -> qualifyColumn ( $ localKey ) ; if ( is_array ( $ foreignKey ) ) { $ query -> where ( $ predecessor -> qualifyColumn ( $ foreignKey [ 0 ] ) , '=' , $ throughParent -> getMorphClass ( ) ) ; $ foreignKey = $ foreignKey [ 1 ] ; } $ second = $ predecessor -> qualifyColumn ( $ prefix . $ foreignKey ) ; $ query -> join ( $ throughParent -> getTable ( ) , $ first , '=' , $ second ) ; if ( $ this -> throughParentInstanceSoftDeletes ( $ throughParent ) ) { $ query -> whereNull ( $ throughParent -> getQualifiedDeletedAtColumn ( ) ) ; } }
Join a through parent table.

@param  \Illuminate\Database\Eloquent\Builder  $query
@param  \Illuminate\Database\Eloquent\Model  $throughParent
@param  \Illuminate\Database\Eloquent\Model  $predecessor
@param  array|string  $foreignKey
@param  array|string  $localKey
@param  string  $prefix
@return void
Join a through parent table .