Skip to content

Commit 21a3cd7

Browse files
authored
[10.x] Allow to pass Arrayable to whereIn and whereNotIn queries (#905)
* Allow to pass Arrayable to in queries * Fix styleCI
1 parent ba18dea commit 21a3cd7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Builder.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laravel\Scout;
44

55
use Illuminate\Container\Container;
6+
use Illuminate\Contracts\Support\Arrayable;
67
use Illuminate\Pagination\LengthAwarePaginator;
78
use Illuminate\Pagination\Paginator;
89
use Illuminate\Support\Traits\Conditionable;
@@ -146,11 +147,15 @@ public function where($field, $value)
146147
* Add a "where in" constraint to the search query.
147148
*
148149
* @param string $field
149-
* @param array $values
150+
* @param \Illuminate\Contracts\Support\Arrayable|array $values
150151
* @return $this
151152
*/
152-
public function whereIn($field, array $values)
153+
public function whereIn($field, $values)
153154
{
155+
if ($values instanceof Arrayable) {
156+
$values = $values->toArray();
157+
}
158+
154159
$this->whereIns[$field] = $values;
155160

156161
return $this;
@@ -160,11 +165,15 @@ public function whereIn($field, array $values)
160165
* Add a "where not in" constraint to the search query.
161166
*
162167
* @param string $field
163-
* @param array $values
168+
* @param \Illuminate\Contracts\Support\Arrayable|array $values
164169
* @return $this
165170
*/
166-
public function whereNotIn($field, array $values)
171+
public function whereNotIn($field, $values)
167172
{
173+
if ($values instanceof Arrayable) {
174+
$values = $values->toArray();
175+
}
176+
168177
$this->whereNotIns[$field] = $values;
169178

170179
return $this;

0 commit comments

Comments
 (0)