diff --git a/src/Rules/UniqueEntryValue.php b/src/Rules/UniqueEntryValue.php index b3f7dfd387a..1fc6283d453 100644 --- a/src/Rules/UniqueEntryValue.php +++ b/src/Rules/UniqueEntryValue.php @@ -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) { diff --git a/src/Rules/UniqueTermValue.php b/src/Rules/UniqueTermValue.php index 8470a2b9769..32614bcc390 100644 --- a/src/Rules/UniqueTermValue.php +++ b/src/Rules/UniqueTermValue.php @@ -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) { diff --git a/src/Rules/UniqueUserValue.php b/src/Rules/UniqueUserValue.php index a69121cee75..80bfb7cf6da 100644 --- a/src/Rules/UniqueUserValue.php +++ b/src/Rules/UniqueUserValue.php @@ -20,7 +20,11 @@ public function validate(string $attribute, mixed $value, Closure $fail): void $this->column ??= $attribute; $existing = User::query() - ->where($this->column, $value) + ->when( + is_array($value), + fn ($query) => $query->whereIn($this->column, $value), + fn ($query) => $query->where($this->column, $value) + ) ->first(); if (! $existing) {