PhoneAndCheck.php 504 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Module\User\Validator;
  3. use App\Module\User\Models\UserPhone;
  4. use UCore\Validator;
  5. use function _\uniq;
  6. /**
  7. * 手机号码是否存在,不存在检查是否可用
  8. *
  9. */
  10. class PhoneAndCheck extends Validator
  11. {
  12. public function validate(mixed $value, array $data): bool
  13. {
  14. $userPhone = UserPhone::query()
  15. ->where('phone', '=', $value)
  16. ->first();
  17. if (!$userPhone) {
  18. return false;
  19. }
  20. return true;
  21. }
  22. }