Skip to content

Commit

Permalink
Support whereNotIn
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentBean committed Aug 15, 2024
1 parent 94a92b4 commit 6becb7e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ public function find(mixed ...$values): ?BaseResource
foreach ($combined as $key => $value) {
if ($baseResource->getCastType($key) === 'date') {
$this->builder->whereDate($key, '=', $value);
} elseif ($baseResource->getCastType($key) === 'guid') {
$this->builder->whereRaw("$key eq $value");
} else {
$this->builder->where($key, '=', $value);
if ($baseResource->getCastType($key) === 'guid') {
$this->builder->whereRaw("$key eq $value");
} else {
$this->builder->where($key, '=', $value);
}
}
}

Expand Down Expand Up @@ -223,6 +225,17 @@ public function whereIn(string $field, array $values): static
return $this;
}

public function whereNotIn(string $field, array $values): static
{
$this->builder->where(function (Builder $builder) use ($field, $values): void {
foreach ($values as $value) {
$builder->where($field, '!=', $value);
}
});

return $this;
}

public function when(mixed $statement, Closure $closure): static
{
if ($statement) {
Expand Down

0 comments on commit 6becb7e

Please sign in to comment.