AdminUser.php 767 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User:林志杰
  5. * Email:[email protected]
  6. * Motto:纵有疾风起,人生不言弃!
  7. * Time:2020/1/4 11:17
  8. */
  9. namespace app\admin\validate;
  10. use think\Validate;
  11. class AdminUser extends Validate
  12. {
  13. protected $rule = [
  14. 'username' => 'require',
  15. 'password' => 'require',
  16. 'captcha' => 'require|checkCaptcha',
  17. ];
  18. protected $message = [
  19. 'username' => '用户名必须',
  20. 'password' => '密码必须',
  21. 'captcha' => '验证码必须',
  22. ];
  23. protected function checkCaptcha($value, $rule, $data = [])
  24. {
  25. if (!captcha_check($value)) {
  26. // 验证码校验失败
  27. return '验证码不正确';
  28. }
  29. return true;
  30. }
  31. }