This commit is contained in:
2023-12-19 14:51:13 +08:00
parent 6621c5f247
commit 21aca8b642
13 changed files with 22 additions and 35 deletions
+7 -3
View File
@@ -23,15 +23,19 @@ class UniqueValidator extends BaseValidator
/**
* @param string $field
* @var string
*/
public string $field;
/**
* @param mixed $value
* @return bool
* @throws
* 检查是否存在
*/
public function trigger(string $field, mixed $value): bool
public function trigger(mixed $value): bool
{
return $this->model::query()->where([$field => $value])->exists() === false;
return $this->model::query()->where([$this->field => $value])->exists() === false;
}