| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Module\User\Validator;
- use App\Module\Outside\Api;
- use App\Module\User\Enums\PhoneStatus;
- use App\Module\User\Models\UserPhone;
- use App\Module\User\User;
- use UCore\Validator;
- use function _\uniq;
- /**
- * 手机号码是否存在,不存在检查是否可用
- *
- */
- class PhoneAndCheck extends Validator
- {
- public function validate(mixed $value, array $data): bool
- {
- $userPhone = UserPhone::query()
- ->where('phone', '=', $value)
- ->first();
- if (!$userPhone) {
- // 注册,绑定手机号码
- /**
- * @var Api\CanPhoneLogin $api
- */
- $api = Api::getApiById(1,\App\Module\Outside\Enums\Api::CanPhoneLogin);
- $res = $api->request($value);
- if(!$res){
- return false;
- }
- }
- return true;
- }
- }
|