diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/src/SearchableTrait.php b/src/SearchableTrait.php index 5ac6e3e..8a90234 100644 --- a/src/SearchableTrait.php +++ b/src/SearchableTrait.php @@ -322,11 +322,14 @@ protected function mergeQueries(Builder $clone, Builder $original) { $original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$tableName}`")); } - $original->setBindings( - array_merge_recursive( - $clone->getBindings(), - $original->getBindings() - ) + // 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); } }