Skip to content

Commit

Permalink
[10.x] Allow to pass Arrayable to whereIn and whereNotIn queries (#…
Browse files Browse the repository at this point in the history
…905)

* Allow to pass Arrayable to in queries

* Fix styleCI
  • Loading branch information
Joel-Jensen authored Feb 5, 2025
1 parent ba18dea commit 21a3cd7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laravel\Scout;

use Illuminate\Container\Container;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Traits\Conditionable;
Expand Down Expand Up @@ -146,11 +147,15 @@ public function where($field, $value)
* Add a "where in" constraint to the search query.
*
* @param string $field
* @param array $values
* @param \Illuminate\Contracts\Support\Arrayable|array $values
* @return $this
*/
public function whereIn($field, array $values)
public function whereIn($field, $values)
{
if ($values instanceof Arrayable) {
$values = $values->toArray();
}

$this->whereIns[$field] = $values;

return $this;
Expand All @@ -160,11 +165,15 @@ public function whereIn($field, array $values)
* Add a "where not in" constraint to the search query.
*
* @param string $field
* @param array $values
* @param \Illuminate\Contracts\Support\Arrayable|array $values
* @return $this
*/
public function whereNotIn($field, array $values)
public function whereNotIn($field, $values)
{
if ($values instanceof Arrayable) {
$values = $values->toArray();
}

$this->whereNotIns[$field] = $values;

return $this;
Expand Down

0 comments on commit 21a3cd7

Please sign in to comment.