laravel-google-captcha maintained by ibehbudov
Description
Google Captcha rule for Laravel validation
Author
Last update
2022/08/24 09:36
(dev-master)
License
Downloads
34
##Google Captcha for Laravel
Installation
composer require ibehbudov/laravel-google-captcha
Publish vendor files
php artisan vendor:publish --tag=google-captcha
Secret key
Open config/google-captcha.php file and edit
return [
'secret_key' => 'google_secret_key'
];
Usage
Inside controller
$request->validate([
'g-recaptcha-response' => new GoogleCaptchaRule()
]);
Inside rule
public function rules()
{
return [
'g-recaptcha-response' => new GoogleCaptchaRule()
];
}
In somewhere as you want
$googleCaptcha = app(GoogleCaptcha::class);
$googleCaptcha->validate($request->post('g-recaptcha-response'));
if($googleCaptcha->fail()) {
return $googleCaptcha->getErrorMessage();
}
else {
// code goes here
}