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
If you want to use v3, please go to: https://github.com/RyanDaDeng/laravel-google-recaptcha-v3
21
+
19
22
# DEMO
20
23
21
24
## Invisible
@@ -32,19 +35,12 @@ This is a package for Google reCAPTCHA v2
32
35
33
36
## Description
34
37
35
-
Google reCAPTCHA v2 is a new mechanism to verify whether the user is bot or not.
36
-
37
-
reCAPTCHA v2 is intended for power users, site owners that want more data about their traffic, and for use cases in which it is not appropriate to show a challenge to the user.
38
-
39
-
For example, a registration page might still use reCAPTCHA v2 for a higher-friction challenge, whereas more common actions like sign-in, searches, comments, or voting might use reCAPTCHA v2.
40
-
41
-
Please check Google site: https://developers.google.com/recaptcha/docs/faq
38
+
If you want to make your own validation rules, you have full access to modify template file, so you can customise your own template by reading through Google official guide for either invisible or inline. https://developers.google.com/recaptcha/docs/display
42
39
43
40
## Features
44
41
45
-
- Score Comparision
46
42
- Support invisible, global and inline badge style
47
-
- Support multiple reCAPTCHA the same page for different forms
43
+
- Support multiple reCAPTCHA on the same page for different forms
48
44
- Support multiple actions to be placed on the same page
49
45
- Support custom implementation on config interface
50
46
- Support custom implementation on request method interface
@@ -77,48 +73,31 @@ If your Laravel framework version <= 5.4, please register the service provider i
After installation, you should see a googlerecaptchav2/field.blade and header.blade file in your views folder and googlerecaptchav2.php in your app/config folder.
94
+
After installation, you should see a googlerecaptchav2/template.blade under views folder and googlerecaptchav2.php in your app/config folder.
99
95
100
96
## Basic Usage
101
97
#### Setting up your Google reCAPTCHA details in config file
102
98
103
99
Please register all details on host_name, site_key, secret_key and site_verify_url.
104
100
105
-
Specify your Score threshold and action in 'setting', e.g.
106
-
```php
107
-
'setting' = [
108
-
[
109
-
'action' => 'contact_us', // Google reCAPTCHA required paramater
110
-
'threshold' => 0.2, // score threshold
111
-
'is_enabled' => false // if this is true, the system will do score comparsion against your threshold for the action
112
-
]
113
-
]
114
-
```
115
-
Note: if you want to enable Score Comparision, you also need to enable is_score_enabled to be true.
116
-
```php
117
-
'is_score_enabled' = true
118
-
```
119
-
120
-
For score comparision, all actions should be registered in googlerecaptchav2 config file under 'setting' section.
121
-
122
101
For more details please check comments in config file.
123
102
124
103
#### Display reCAPTCHA v2
@@ -127,18 +106,15 @@ For more details please check comments in config file.
127
106
Include div with an ID inside your form, e.g.
128
107
129
108
```html
130
-
<divid="contact_us_id"></div>
109
+
<divid="form_id_1"></div>
110
+
<divid="form_id_2"></div>
131
111
```
132
112
133
113
Include Template script in your bottom/header of your page, params should follow 'ID'=>'Action', e.g.
134
114
135
115
```PHP
136
-
{!! GoogleReCaptchav2::render(
137
-
[
138
-
'contact_us_id'=>'contact_us', // the div id=contact_us_id maps to action name contact_us
139
-
'signin_id'=>'registration', // the div id=signin_id maps to action name registration
140
-
'register_id'=>'registration' // the div id=register_id maps to action name registration
Go to /index and click submit button on contact us form and you should see an error message that 'Score does not meet the treshhold' because the threshold >2. You can play around the controller to see all outcomes. Importantly, you need to wait the script to load and render the token before clicking the submit button.
297
260
298
261
## Advanced Usage
299
262
263
+
#### Custom implementation on Template
264
+
265
+
After publish views, a blade file created under googlerecaptchav2, you can customise it and change template value in config file, e.g. if your template is saved in resources/views/test/template, you should put values as below:
266
+
```PHP
267
+
[
268
+
...
269
+
'template' => 'test.template'
270
+
...
271
+
]
272
+
```
273
+
274
+
300
275
#### Custom implementation on Config
301
276
302
277
For some users, they might store the config details in their own storage e.g database. You can create your own class and implement:
Remember to register it in your own service provider
309
284
310
285
```php
311
286
$this->app->bind(
312
-
ReCaptchaConfigv2Interface::class,
287
+
ReCaptchaConfigV2Interface::class,
313
288
YourOwnCustomImplementation::class
314
289
);
315
290
```
@@ -318,7 +293,7 @@ Remember to register it in your own service provider
318
293
319
294
The package has two default options to verify: Guzzle and Curl, if you want to use your own request method, You can create your own class and implement
0 commit comments