diff --git a/src/Rules/UniqueEntryValue.php b/src/Rules/UniqueEntryValue.php index b3f7dfd387..1fc6283d45 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 8470a2b976..32614bcc39 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 a69121cee7..80bfb7cf6d 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) {