smkbd/recaptcha-checkbox 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

smkbd/recaptcha-checkbox

最新稳定版本:v1.0.0

Composer 安装命令:

composer require smkbd/recaptcha-checkbox

包简介

Google reCAPTCHA v2 Checkbox

README 文档

README

This package allows you implement Google reCAPTCHA v2 Checkbox in any form without any hassle.

Version Support

Laravel Version Support
Laravel 10 ✔️
Laravel 9 Not tested
Laravel 8 Not tested
Laravel 7 Not tested
Laravel 6 Not tested

Installation

composer require smkbd/recaptcha-checkbox

Configuration

Add the following environment values in your .env file

RECAPTCHA_SITE_KEY=recaptcha_site_key_here
RECAPTCHA_SECRET_KEY=recaptcha_secret_key_here

You can obtain these keys from Google reCAPTCHA Admin

Usage

To enable reCAPTCHA in a form, you need to make two changes, one in the <form> and one in the controller method which accepts the form request.

Form

Include the blade directive @recaptcha where you want the checkbox to appear.

Controller

In the controller, all you need is to use \Smkbd\RecaptchaCheckbox\RecaptchaRequest $request instead of \Illuminate\Http\Client\Request $request as the method argument.

For example, in routes/web.php

Route::post('/comments', [\App\Http\Controllers\CommentController::class, 'store'])->name('comments.store');

In app/Http/Controllers/CommentController.php

use Smkbd\RecaptchaCheckbox\RecaptchaRequest;

class CommentController extends Controller{
    ...

    public function store(RecaptchaRequest $request){
        
        // Your logic here
    
    }

    ...
}

You can appply your own validation inside the controller as you usually do. But RecaptchaRequest will first validate the request if it comes with a valid captcha fulfillment.

Translation

To translate the messages for captcha, you need to publish the vendor files first.

php artisan vendor:publish --tag=recaptcha

This will publish the translation files in resources/lang/vendor/recaptcha directory.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-12