src/Franzose/ClosureTable/Models/Entity.php
protected function subqueryClosureBy($column, $withSelf = false)
    {
        $self = $this;

        return $this->whereIn($this->getQualifiedKeyName(), function ($qb) use ($self, $column, $withSelf) {
            switch ($column) {
                case 'ancestor':
                    $selectedColumn = $self->closure->getAncestorColumn();
                    $whereColumn = $self->closure->getDescendantColumn();
                    break;

                case 'descendant':
                    $selectedColumn = $self->closure->getDescendantColumn();
                    $whereColumn = $self->closure->getAncestorColumn();
                    break;
            }

            $depthOperator = ($withSelf === true ? '>=' : '>');

            return $qb->select($selectedColumn)
                ->from($self->closure->getTable())
                ->where($whereColumn, '=', $self->getKey())
                ->where($self->closure->getDepthColumn(), $depthOperator, 0);
        });
    }
protected function subqueryClosureBy($column, $withSelf = false)
    {
        $self = $this;

        return $this->whereIn($this->getQualifiedKeyName(), function ($qb) use ($self, $column, $withSelf) {
            switch ($column) {
                case 'ancestor':
                    $selectedColumn = $self->closure->getAncestorColumn();
                    $whereColumn = $self->closure->getDescendantColumn();
                    break;

                case 'descendant':
                    $selectedColumn = $self->closure->getDescendantColumn();
                    $whereColumn = $self->closure->getAncestorColumn();
                    break;
            }

            $depthOperator = ($withSelf === true ? '>=' : '>');

            return $qb->select($selectedColumn)
                ->from($self->closure->getTable())
                ->where($whereColumn, '=', $self->getKey())
                ->where($self->closure->getDepthColumn(), $depthOperator, 0);
        });
    }
protected function subqueryClosureBy ( $ column , $ withSelf = false ) { $ self = $ this ; return $ this -> whereIn ( $ this -> getQualifiedKeyName ( ) , function ( $ qb ) use ( $ self , $ column , $ withSelf ) { switch ( $ column ) { case 'ancestor' : $ selectedColumn = $ self -> closure -> getAncestorColumn ( ) ; $ whereColumn = $ self -> closure -> getDescendantColumn ( ) ; break ; case 'descendant' : $ selectedColumn = $ self -> closure -> getDescendantColumn ( ) ; $ whereColumn = $ self -> closure -> getAncestorColumn ( ) ; break ; } $ depthOperator = ( $ withSelf === true ? '>=' : '>' ) ; return $ qb -> select ( $ selectedColumn ) -> from ( $ self -> closure -> getTable ( ) ) -> where ( $ whereColumn , '=' , $ self -> getKey ( ) ) -> where ( $ self -> closure -> getDepthColumn ( ) , $ depthOperator , 0 ) ; } ) ; }
Builds closure table "where in" query on the given column.

@param string $column
@param bool $withSelf
@return QueryBuilder
Builds closure table where in query on the given column .