https://github.com/antonioribeiro/twill-capsule-google-recaptcha
Google reCAPTCHA Twill Capsule
https://github.com/antonioribeiro/twill-capsule-google-recaptcha
Last synced: 4 months ago
JSON representation
Google reCAPTCHA Twill Capsule
- Host: GitHub
- URL: https://github.com/antonioribeiro/twill-capsule-google-recaptcha
- Owner: antonioribeiro
- Created: 2022-09-06T09:44:34.000Z (about 3 years ago)
- Default Branch: 1.x
- Last Pushed: 2022-09-06T10:00:31.000Z (about 3 years ago)
- Last Synced: 2025-02-24T03:23:38.866Z (8 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Support: Support/GoogleRecaptcha.php
Awesome Lists containing this project
README
# Google reCAPTCHA v3 Twill Capsule
## Installation
#### Clone / Copy this capsule into `app/Twill/Capsules/GoogleRecaptchas`
#### Create debugging routes to check if it's all good
```php
Route::prefix('/debug')->group(function () {
Route::get('/google-recaptcha-3', [GoogleRecaptchaFrontController::class, 'show'])->name(
'google-recaptcha.show',
);Route::post('/google-recaptcha-3', [GoogleRecaptchaFrontController::class, 'store'])->name(
'google-recaptcha.store',
);
});
```#### Translate validation messages on validation.php
```php
'google_recaptcha' => 'Failed invisible Google reCAPTCHA, please try again.',
```#### Test it out
Head to: http://site.com/debug/google-recaptcha-3
#### Captcha keys works both on .env or in the CMS settings, but .env trumps the CMS settings
```dotenv
GOOGLE_RECAPTCHA_SITE_KEY=61df2g3hjkj7hgf6df54g3hj2kl3k4j5h6G
GOOGLE_RECAPTCHA_PRIVATE_KEY=6Lg5h43jkl45k6jh7g6h5j4kl3nj5k4l3P
GOOGLE_RECAPTCHA_ENABLED=true
```#### Check the working form example
File: app/Twill/Capsules/GoogleRecaptchas/resources/views/front/form.blade.php
#### Use the validator
```php
use App\Twill\Capsules\GoogleRecaptchas\Support\Validator as GoogleRecaptchaValidator;$request->validate([
'g-recaptcha-response' => ['required', 'string', new GoogleRecaptchaValidator()],
]);
```## Contribute
Please contribute to this project by submitting pull requests.