Skip to content

Commit

Permalink
Support arrays in UniqueTermValue rule
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Aug 16, 2024
1 parent 5e97e5c commit 54d1005
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Rules/UniqueTermValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
}

$existing = $query
->where($attribute, $value)
->when(
is_array($value),
fn ($query) => $query->whereIn($attribute, $value),
fn ($query) => $query->where($attribute, $value)
)
->first();

if (! $existing) {
Expand Down

0 comments on commit 54d1005

Please sign in to comment.