PhoneValidator.php 557 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Module\User\Validator;
  3. use App\Module\User\Models\UserPhone;
  4. use UCore\Validator;
  5. use App\Models\Hp\User;
  6. /**
  7. * 手机登录检测,存在true
  8. * 并写入 Validation.user
  9. *
  10. */
  11. class PhoneValidator extends Validator
  12. {
  13. public function validate($value, array $data): bool
  14. {
  15. $user = UserPhone::query()->where('phone','=',$value)
  16. ->first();
  17. // dd($user,$value);
  18. if ($user) {
  19. $this->validationSet('user',$user);
  20. return true;
  21. }
  22. return false;
  23. }
  24. }