diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 7c3baa2e1e2e..cd1c75b52bdf 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -1289,7 +1289,7 @@ public function addNestedWhereQuery($query, $boolean = 'and') $this->wheres[] = compact('type', 'query', 'boolean'); - $this->addBinding($query->getBindings(), 'where'); + $this->addBinding($query->getRawBindings()['where'], 'where'); } return $this; diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 467cb8a12b51..411bb356234a 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -1039,6 +1039,15 @@ public function testNestedWheres() $this->assertEquals([0 => 'foo', 1 => 'bar', 2 => 25], $builder->getBindings()); } + public function testNestedWhereBindings() + { + $builder = $this->getBuilder(); + $builder->where('email', '=', 'foo')->where(function ($q) { + $q->selectRaw('?', ['ignore'])->where('name', '=', 'bar'); + }); + $this->assertEquals([0 => 'foo', 1 => 'bar'], $builder->getBindings()); + } + public function testFullSubSelects() { $builder = $this->getBuilder();