diff --git a/src/SearchableTrait.php b/src/SearchableTrait.php index 49ce834..b1e3baf 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); } }