PhoneUValidator.php 459 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Module\User\Validator;
  3. use App\Module\User\Models\UserPhone;
  4. use DCore\Validator;
  5. use App\Module\User\Models\User;
  6. /**
  7. * 手机号码绑定,有 true
  8. *
  9. */
  10. class PhoneUValidator extends Validator
  11. {
  12. public function validate($value, array $data): bool
  13. {
  14. $user = UserPhone::query()->where('phone','=',$value)
  15. ->first();
  16. if ($user) {
  17. return true;
  18. }
  19. return false;
  20. }
  21. }