dizatech / cutlet-recaptcha
A package to use google recaptcha v2 with component and rule in laravel apps.
v1.0.3
2023-09-02 13:13 UTC
Requires
- php: ^7.3|^8.1
- laravel/framework: ^7.0|^8.0|^9.0|^10.0
This package is auto-updated.
Last update: 2024-10-31 00:23:33 UTC
README
Installation
composer require va/cutlet-recaptcha
Publish Config file
php artisan vendor:publish --tag=cutlet-recaptcha
Usage
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' => 'شما به عنوان ربات تشخیص داده شدهاید'
];
Requirements:
- PHP v7.0 or above
- Laravel v7.0 or above