1. Go to this page and download the library: Download buzz/laravel-google-captcha library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
buzz / laravel-google-captcha example snippets
/*
* Secret key and Site key get on https://www.google.com/recaptcha
* */
return [
'secret' => env('CAPTCHA_SECRET', 'default_secret'),
'sitekey' => env('CAPTCHA_SITEKEY', 'default_sitekey'),
/**
* @var string|null Default ``null``.
* Custom with function name (example customRequestCaptcha) or class@method (example \App\CustomRequestCaptcha@custom).
* Function must be return instance, read more in repo ``https://github.com/thinhbuzz/laravel-google-captcha-examples``
*/
'request_method' => null,
'options' => [
'multiple' => false,
'lang' => app()->getLocale(),
],
'attributes' => [
'theme' => 'light'
],
];
function customRequestCaptcha(){
return new \ReCaptcha\RequestMethod\Post();
}
namespace App;
class CustomRequestCaptcha
{
public function custom()
{
return new \ReCaptcha\RequestMethod\Post();
}
}
use Validator;
use Illuminate\Support\Facades\Input;
$validate = Validator::make(Input::all(), [
'g-recaptcha-response' => '
// Prevent validation error on captcha
CaptchaFacade::shouldReceive('verify')
->andReturn(true);
// Provide hidden input for your ' when testing multiple captchas on a single page
CaptchaFacade::shouldReceive('displayJs');
CaptchaFacade::shouldReceive('displayMultiple');
CaptchaFacade::shouldReceive('multiple');