CaptchaService.php 473 B

123456789101112131415161718192021
  1. <?php
  2. namespace think\captcha;
  3. use think\Route;
  4. use think\Service;
  5. use think\Validate;
  6. class CaptchaService extends Service
  7. {
  8. public function boot(Route $route)
  9. {
  10. $route->get('captcha/[:config]', "\\think\\captcha\\CaptchaController@index");
  11. Validate::maker(function ($validate) {
  12. $validate->extend('captcha', function ($value) {
  13. return captcha_check($value);
  14. }, ':attribute错误!');
  15. });
  16. }
  17. }