Laravel GeeTest Captcha for Laravel 9-10-11
salahhusa9/laravel-geetest-captcha is a Laravel package for laravel geetest captcha for laravel 9-10-11.
It currently has 16 GitHub stars and 2.955 downloads on Packagist (latest version v0.0.3).
Install it with composer require salahhusa9/laravel-geetest-captcha.
Discover more Laravel packages by salahhusa9
or browse all Laravel packages to compare alternatives.
Last updated
Laravel Geetest Captcha is a package that provides a simple way to integrate Geetest Captcha in your Laravel application.
Does your business depend on our contributions? Reach out and support us on Github sponsor. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
composer require salahhusa9/laravel-geetest-captcha
@geetestCaptchaAssets() in head tag in your layout file:<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
@geetestCaptchaAssets()
</head>
<body>
...
</body>
</html>
You can use in form like this:
In first add @geetestCaptchaInit('captcha-id') in footer of page as script tag, captcha-id is the id of the captcha div.
<form method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" id="email" class="form-control" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control" required>
</div>
<div class="form-group">
<div id="captcha-id">
<!-- hire we render geetest captcha -->
</div>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
@geetestCaptchaInit('captcha-id')
and for validation you can use geetest_captcha rule in your controller like this:
use Salahhusa9\GeetestCaptcha\Rules\GeetestCaptchaValidate;
public function login(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required',
'geetest_captcha' => ['required', new GeetestCaptchaValidate]
]);
// your logic
}
You can use in middleware like this:
use Salahhusa9\GeetestCaptcha\Http\Middleware\ValidateGeetestCaptcha;
Route::post('login', [LoginController::class, 'login'])->middleware(ValidateGeetestCaptcha::class);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.