A package to use google recaptcha v2 with component and rule in laravel apps.
MIT License
composer require va/cutlet-recaptcha
php artisan vendor:publish --tag=cutlet-recaptcha
Set the values for google api in .env file:
GOOGLE_RECAPTCHA_SITE_KEY=
GOOGLE_RECAPTCHA_SECRET_KEY=
You can add this tag in blade files:
<x-cutlet-recaptcha :has-error="$errors->has('g-recaptcha-response')"></x-cutlet-recaptcha>
and in the validation parts:
protected function validateLogin(Request $request)
{
$request->validate([
$this->username() => ['required', 'string'],
'password' => ['required', 'string'],
'g-recaptcha-response' => ['required', 'cutlet_recaptcha']
]);
}
and you can customize the language and validation message in config file;
return [
'language' => 'fa',
'site_key' => env('GOOGLE_RECAPTCAH_SITE_KEY'),
'secret_key' => env('GOOGLE_RECAPTCAH_SECRET_KEY'),
'message' => 'شما به عنوان ربات تشخیص داده شدهاید'
];