Downloads
Stars
Version
Easily add Google's V2 and Invisable reCaptcha to your forms;
This code is borrowed heavily from anhskohbo/no-captcha
composer require daikazu/laravel-recaptcha
NOTE This package supports Laravel 5.5 auto-discovery, so you can skip the setup if you are using 5.5 and above.
Public Config File recaptcha.php
php artisan vendor:publish --provider="Daikazu\LaravelRecaptcha\ReCaptchaServiceProvider"
Add your RECAPTCHA_SECRET
and RECAPTCHA_SITEKEY
into your .env
file:
RECAPTCHA_SECRET=secret-key
RECAPTCHA_SITEKEY=site-key
(You can obtain them from here)
With default options :
{!! ReCaptcha::renderJs() !!}
With language support or onloadCallback option :
{!! ReCaptcha::renderJs('fr', true, 'recaptchaCallback') !!}
{!! ReCaptcha::displayWidget() !!}
With custom attributes (theme, size, callback ...) :
{!! ReCaptcha::displayWidget(['data-theme' => 'dark']) !!}
{!! ReCaptcha::displayButton( 'Button Text', ['data-callback' => 'onFormSubmit', 'class' => 'button is-info']) !!}
Add 'g-recaptcha-response' => 'required|recaptcha'
to to validation rules array;
$validate = Validator::make(Input::all(), [
'g-recaptcha-response' => 'required|recaptcha'
]);
Then check for reCAPTCHA errors in the form:
@if ($errors->has('g-recaptcha-response'))
<span class="help-block">
<strong>{{ $errors->first('g-recaptcha-response') }}</strong>
</span>
@endif
Comming soon!