InviteCode.php 481 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Module\User\Validator;
  3. use App\Module\User\Models\User;
  4. use UCore\Validator;
  5. class InviteCode extends Validator
  6. {
  7. /**
  8. * @param mixed $value
  9. * @param array $data
  10. * @return bool
  11. * 邀请码验证
  12. */
  13. public function validate(mixed $value, array $data): bool
  14. {
  15. $data = User::query()->where('invite_code', $value)->first();
  16. if (empty($data)) {
  17. return false;
  18. }
  19. return true;
  20. }
  21. }