定制 afromansr/laravel-math-captcha 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

afromansr/laravel-math-captcha

最新稳定版本:v1.0

Composer 安装命令:

composer require afromansr/laravel-math-captcha

包简介

A laravel framework math-captcha package

README 文档

README

A simple math-captcha based on Laravel Simple Captcha
Captcha is the most used technique for preventing spam in form submission. The Laravel Math Captcha package will help you to prevent spam form submission. It's a really simple and lightweight Laravel package for captcha.

Features of Laravel Math Captcha

  • Lightweight
  • Simple & easy to use
  • Support Laravel 5, 6
  • Captcha validation rules
  • Customizable math operation

Installation

Use [Composer] to install the package:

$ composer require afromansr/laravel-math-captcha

Usage

Use the getCaptchaBox method, In the form where you need to add captcha.

{!!getCaptchaBox()!!}

Optional: You can change the captcha answer input box name. By default, it is _answer

{!!getCaptchaBox('txtAnswer')!!}

Example

<form action="#" method="POST">
    @csrf
    
    <div class="form-group">
        <label for="name">Name</label>
        <input type="text" class="form-control">
    </div>
    <div class="form-group">
        <label for="email">E-mail</label>
        <input type="text" class="form-control">
    </div>
    
    <div class="form-group">
    {!!getCaptchaBox()!!}
    </div>

    <button class="btn btn-sm btn-default">Submit</button>
</form>

Custom Captcha Box

For adjusting the captcha box in your markup, you can make the captcha box using the getCaptchaQuestion method.

<p>Captcha</p>
<p>{{getCaptchaQuestion()}}</p>
<input name="_answer" type="number">

Custom Captcha Math Operation

By default, captcha will auto generate math questions with random math operators from addition, subtraction or multiplication. To customise this setting, you need to publish the config file.

$ php artisan vendor:publish --tag=captcha-config

Validation

Use math_captcha validation rules where you handle the request.

public function handleForm(Request $request)
{
     $this->validate( $request, [
         '_answer'=>'required|simple_captcha'
     ]);
}

统计信息

  • 总下载量: 2.45k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-01