You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/maize-tech/laravel-google-recaptcha-v3)
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
8
+
A Laravel package that provides a simple and elegant integration of Google reCAPTCHA v3 for your Laravel applications. This package includes a Blade directive for easy frontend integration and a validation rule for backend verification with customizable score thresholds.
9
9
10
10
## Support us
11
11
@@ -23,39 +23,207 @@ You can install the package via composer:
You can obtain your site key and secret key from the [Google reCAPTCHA Admin Console](https://www.google.com/recaptcha/admin).
97
+
52
98
## Usage
53
99
100
+
### Frontend Integration
101
+
102
+
Add the reCAPTCHA script to your Blade templates using the `@recaptcha` directive. You can customize the badge position by passing one of the available badge positions:
'g-recaptcha-response.required' => 'Please complete the reCAPTCHA verification.',
200
+
];
201
+
}
202
+
}
203
+
```
204
+
205
+
### JavaScript Helper
206
+
207
+
The package automatically provides a global `window.recaptcha()` function that you can use to get the reCAPTCHA token:
208
+
209
+
```javascript
210
+
// Get token with default action 'submit'
211
+
consttoken=awaitwindow.recaptcha();
212
+
213
+
// Get token with custom action
214
+
consttoken=awaitwindow.recaptcha('login');
215
+
```
216
+
217
+
This function returns a Promise that resolves to the reCAPTCHA token, or `null` if reCAPTCHA is not available or fails.
218
+
219
+
### Disabling reCAPTCHA
220
+
221
+
You can disable reCAPTCHA validation by setting the `enabled` configuration to `false` or by setting the `GOOGLE_RECAPTCHA_V3_ENABLED` environment variable to `false`. This is useful for local development or testing environments.
222
+
223
+
When disabled:
224
+
- The `@recaptcha` directive will not render any scripts
225
+
- The validation rule will pass without making any API calls to Google
0 commit comments