TaoLer/vendor/topthink/think-captcha/src/CaptchaService.php

24 lines
533 B
PHP
Raw Normal View History

2020-01-01 13:17:19 +08:00
<?php
namespace think\captcha;
use think\Route;
use think\Service;
use think\Validate;
class CaptchaService extends Service
{
2020-05-20 11:33:27 +08:00
public function boot()
2020-01-01 13:17:19 +08:00
{
Validate::maker(function ($validate) {
$validate->extend('captcha', function ($value) {
return captcha_check($value);
}, ':attribute错误!');
});
2020-05-20 11:33:27 +08:00
$this->registerRoutes(function (Route $route) {
$route->get('captcha/[:config]', "\\think\\captcha\\CaptchaController@index");
});
2020-01-01 13:17:19 +08:00
}
}