jbrathod / math-captcha
在单个网站上使用多次的验证码
dev-main
2022-08-02 09:35 UTC
This package is not auto-updated.
Last update: 2024-09-24 23:28:12 UTC
README
将在单个网站中的多个页面/位置使用的一个验证码。
安装指南
composer require jbrathod/math-captcha
在 config/app.php
中找到 providers
键并注册 Captcha 服务提供者。
'providers' => [ // ... 'Jbrathod\MathCaptcha\MathCaptchaServiceProvider', ]
对于 Laravel 5.1+
'providers' => [ // ... Jbrathod\MathCaptcha\MathCaptchaServiceProvider::class, ]
用法
将验证码图片添加到表单中(注意:“contact-us”是页面名称)
<img src="{{ app('mathcaptcha')->image('contact-us') }}"/>
验证验证码
将 'captcha' => 'required|mathcaptcha:contact-us'
添加到规则数组中。
$this->validate($request, [ 'captcha' => 'required|mathcaptcha:contact-us', ]);
在表单提交无错误后重置验证码
app('mathcaptcha')->reset('contact-us');