Skip to content

Commit a0b72c5

Browse files
authored
Update README.md
1 parent 1603568 commit a0b72c5

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,51 @@ Example Usage
155155
GoogleReCaptchaV3::verifyResponse($request->input('g-recaptcha-response'))->getMessage()
156156
```
157157

158+
## Sample Usage
159+
160+
Register your action in config:
161+
``` php
162+
'setting' => [
163+
[
164+
'action' => 'contact_us',
165+
'threshold' => 2,
166+
'score_comparision' => true
167+
]
168+
]
169+
```
170+
171+
Register two routes in web.php
172+
``` php
173+
Route::get('/send', 'ReCaptchaController@index');
174+
Route::post('/verify', 'ReCaptchaController@verify');
175+
```
176+
177+
Create two functions in controller:
178+
``` php
179+
public function verify(Request $request)
180+
{
181+
dd(GoogleReCaptchaV3::verifyResponse($request->input('g-recaptcha-response'))->getMessage());
182+
}
183+
public function send(Request $request)
184+
{
185+
return view('index');
186+
}
187+
```
188+
189+
Create your form:
190+
``` php
191+
{!! GoogleReCaptchaV3::requireJs() !!}
192+
193+
<form method="POST" action="/verify">
194+
@csrf
195+
{!! GoogleReCaptchaV3::render('contact_us') !!}
196+
197+
<input type="submit" value="submit">
198+
</form>
199+
```
200+
201+
Submit the form and you should see an error message that Score does not meet the treshhold as we set 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 input before clicking the submit button.
202+
158203
## Advanced Usage
159204

160205
#### Custom implementation on Config

0 commit comments

Comments
 (0)