public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
    {
        $table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();

        $query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());

        if ($this->throughParentSoftDeletes()) {
            $query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
        }

        return $query->select($columns)->whereColumn(
            $parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
        );
    }
public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
    {
        $table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();

        $query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());

        if ($this->throughParentSoftDeletes()) {
            $query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
        }

        return $query->select($columns)->whereColumn(
            $parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
        );
    }
public function getRelationExistenceQueryForThroughSelfRelation ( Builder $ query , Builder $ parentQuery , $ columns = [ '*' ] ) { $ table = $ this -> throughParent -> getTable ( ) . ' as ' . $ hash = $ this -> getRelationCountHash ( ) ; $ query -> join ( $ table , $ hash . '.' . $ this -> secondLocalKey , '=' , $ this -> getQualifiedFarKeyName ( ) ) ; if ( $ this -> throughParentSoftDeletes ( ) ) { $ query -> whereNull ( $ hash . '.' . $ this -> throughParent -> getDeletedAtColumn ( ) ) ; } return $ query -> select ( $ columns ) -> whereColumn ( $ parentQuery -> getQuery ( ) -> from . '.' . $ this -> localKey , '=' , $ hash . '.' . $ this -> firstKey ) ; }
Add the constraints for a relationship query on the same table as the through parent.

@param  \Illuminate\Database\Eloquent\Builder  $query
@param  \Illuminate\Database\Eloquent\Builder  $parentQuery
@param  array|mixed  $columns
@return \Illuminate\Database\Eloquent\Builder
Add the constraints for a relationship query on the same table as the through parent .