Skip to content

Commit

Permalink
Merge pull request #127 from n1crack/master
Browse files Browse the repository at this point in the history
fix for bindings order when using where clause
  • Loading branch information
nicolaslopezj committed Dec 16, 2016
2 parents 25d4a1a + c79778d commit 1351b1b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/SearchableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public function scopeSearchRestricted(Builder $q, $search, $restriction, $thresh

$this->makeGroupBy($query);

$clone_bindings = $query->getBindings();
$query->setBindings([]);

$this->addBindingsToQuery($query, $this->search_bindings);
$this->addBindingsToQuery($query, $clone_bindings);

if(is_callable($restriction)) {
$query = $restriction($query);
Expand Down Expand Up @@ -337,6 +341,12 @@ protected function mergeQueries(Builder $clone, Builder $original) {
} else {
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as `{$tableName}`"));
}
$original->mergeBindings($clone->getQuery());

$original->setBindings(
array_merge_recursive(
$clone->getBindings(),
$original->getBindings()
)
);
}
}

0 comments on commit 1351b1b

Please sign in to comment.