From 54d1005ffa9a740b40efde7425a6cd7659f3a282 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 16 Aug 2024 13:11:28 +0100 Subject: [PATCH] Support arrays in `UniqueTermValue` rule --- src/Rules/UniqueTermValue.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) {