This library provides support for Google reCAPTCHA v3 in Laravel. This library makes it easy to add reCAPTCHA to your Laravel application to protect against spam and bots.
You can install the package via composer:
composer require nguyendachuy/laravel-recaptcha3
You can publish config file with:
php artisan vendor:publish --tag="recaptcha-config"
return [
/*
|--------------------------------------------------------------------------
| The reCAPTCHA site key provided by Google
|--------------------------------------------------------------------------
|
| Here you can set the sitekey
*/
'sitekey' => env('GOOGLE_CAPTCHA_SITEKEY', null),
/*
|--------------------------------------------------------------------------
| The reCAPTCHA secret key provided by Google
|--------------------------------------------------------------------------
|
| Here you can set the secet
*/
'secret' => env('GOOGLE_CAPTCHA_SECRET', null)
];
Google reCAPTCHA documentation: https://developers.google.com/recaptcha/docs/v3
This directive imports the recaptcha JavaScript library and configures it with your site key.
<body>
{{-- your app --}}
{{-- Default action is "form" --}}
@recaptchaJs
{{-- or custom action --}}
@recaptchaJs('form')
</body>
Use on the form
<form>
{{-- your input --}}
{{-- Default name is "g-recaptcha-response" --}}
@recaptchaInput
{{-- or custom name --}}
@recaptchaInput('custom-name')
</form>
Use on the validator
$request->validate([
'g-recaptcha-response' => 'captcha'
]);
Optimizing Views
php artisan view:clear
The MIT License (MIT). Please see License File for more information.