src/SearchableTrait.php
protected function mergeQueries(Builder $clone, Builder $original) {
        $tableName = DB::connection($this->connection)->getTablePrefix() . $this->getTable();
        if ($this->getDatabaseDriver() == 'pgsql') {
            $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$tableName}"));
        } else {
            $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$tableName}`"));
        }

        // First create a new array merging bindings
        $mergedBindings = array_merge_recursive(
            $clone->getBindings(),
            $original->getBindings()
        );

        // Then apply bindings WITHOUT global scopes which are already included. If not, there is a strange behaviour
        // with some scope's bindings remaning
        $original->withoutGlobalScopes()->setBindings($mergedBindings);
    }
protected function mergeQueries(Builder $clone, Builder $original) {
        $tableName = DB::connection($this->connection)->getTablePrefix() . $this->getTable();
        if ($this->getDatabaseDriver() == 'pgsql') {
            $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$tableName}"));
        } else {
            $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$tableName}`"));
        }

        // First create a new array merging bindings
        $mergedBindings = array_merge_recursive(
            $clone->getBindings(),
            $original->getBindings()
        );

        // Then apply bindings WITHOUT global scopes which are already included. If not, there is a strange behaviour
        // with some scope's bindings remaning
        $original->withoutGlobalScopes()->setBindings($mergedBindings);
    }
protected function mergeQueries ( Builder $ clone , Builder $ original ) { $ tableName = DB :: connection ( $ this -> connection ) -> getTablePrefix ( ) . $ this -> getTable ( ) ; if ( $ this -> getDatabaseDriver ( ) == 'pgsql' ) { $ original -> from ( DB :: connection ( $ this -> connection ) -> raw ( "({$clone->toSql()}) as {$tableName}" ) ) ; } else { $ original -> from ( DB :: connection ( $ this -> connection ) -> raw ( "({$clone->toSql()}) as `{$tableName}`" ) ) ; } // First create a new array merging bindings $ mergedBindings = array_merge_recursive ( $ clone -> getBindings ( ) , $ original -> getBindings ( ) ) ; // Then apply bindings WITHOUT global scopes which are already included. If not, there is a strange behaviour // with some scope's bindings remaning $ original -> withoutGlobalScopes ( ) -> setBindings ( $ mergedBindings ) ; }
Merge our cloned query builder with the original one.

@param \Illuminate\Database\Eloquent\Builder $clone
@param \Illuminate\Database\Eloquent\Builder $original
Merge our cloned query builder with the original one .