diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 710d0a3a568c..5cacbbd6a021 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -1110,12 +1110,12 @@ public function whereNotNull($columns, $boolean = 'and') * Add a where between statement to the query. * * @param string|\Illuminate\Database\Query\Expression $column - * @param array $values + * @param iterable $values * @param string $boolean * @param bool $not * @return $this */ - public function whereBetween($column, array $values, $boolean = 'and', $not = false) + public function whereBetween($column, iterable $values, $boolean = 'and', $not = false) { $type = 'between'; @@ -1148,10 +1148,10 @@ public function whereBetweenColumns($column, array $values, $boolean = 'and', $n * Add an or where between statement to the query. * * @param string $column - * @param array $values + * @param iterable $values * @return $this */ - public function orWhereBetween($column, array $values) + public function orWhereBetween($column, iterable $values) { return $this->whereBetween($column, $values, 'or'); } @@ -1172,11 +1172,11 @@ public function orWhereBetweenColumns($column, array $values) * Add a where not between statement to the query. * * @param string $column - * @param array $values + * @param iterable $values * @param string $boolean * @return $this */ - public function whereNotBetween($column, array $values, $boolean = 'and') + public function whereNotBetween($column, iterable $values, $boolean = 'and') { return $this->whereBetween($column, $values, $boolean, true); } @@ -1198,10 +1198,10 @@ public function whereNotBetweenColumns($column, array $values, $boolean = 'and') * Add an or where not between statement to the query. * * @param string $column - * @param array $values + * @param iterable $values * @return $this */ - public function orWhereNotBetween($column, array $values) + public function orWhereNotBetween($column, iterable $values) { return $this->whereNotBetween($column, $values, 'or'); } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 55b02d9b5ae8..83cbf0702f85 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -673,6 +673,17 @@ public function testWhereBetweens() $builder->select('*')->from('users')->whereBetween('id', [new Raw(1), new Raw(2)]); $this->assertSame('select * from "users" where "id" between 1 and 2', $builder->toSql()); $this->assertEquals([], $builder->getBindings()); + + $builder = $this->getBuilder(); + $period = now()->toPeriod(now()->addDay()); + $builder->select('*')->from('users')->whereBetween('created_at', $period); + $this->assertSame('select * from "users" where "created_at" between ? and ?', $builder->toSql()); + $this->assertEquals($period->toArray(), $builder->getBindings()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->whereBetween('id', collect([1, 2])); + $this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql()); + $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings()); } public function testWhereBetweenColumns()