PHP code example of buzz / laravel-h-captcha

1. Go to this page and download the library: Download buzz/laravel-h-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-h-captcha example snippets



/*
 * Secret key and Site key get on https://dashboard.hcaptcha.com/sites
 * */
return [
    'secret' => env('CAPTCHA_SECRET', 'default_secret'),
    'sitekey' => env('CAPTCHA_SITEKEY', 'default_sitekey'),
    // \GuzzleHttp\Client used is the default client
    'http_client' => \Buzz\LaravelHCaptcha\HttpClient::class,
    'options' => [
        'multiple' => false,
        'lang' => app()->getLocale(),
    ],
    'attributes' => [
        'theme' => 'light'
    ],
];

{!! app('captcha')->display($attributes) !!}

{!! Captcha::display($attributes) !!}

{!! Form::captcha($attributes) !!}

{!! app('captcha')->display($attributes = [], $options = ['lang'=> 'vi']) !!}

// element attributes
$attributes = [
    'data-theme' => 'dark',
    'data-type' => 'audio',
];

// package options
$options = [
    'data-theme' => 'dark',
    'data-type'	=> 'audio',
];

use Validator;
use Illuminate\Support\Facades\Input;

$validate = Validator::make(Input::all(), [
    'h-captcha-response' => '

// Prevent validation error on captcha
        CaptchaFacade::shouldReceive('verify')
            ->andReturn(true);
            
// Provide hidden input for your 'hen testing multiple captchas on a single page
        CaptchaFacade::shouldReceive('displayJs');
        CaptchaFacade::shouldReceive('displayMultiple');
        CaptchaFacade::shouldReceive('multiple');

php artisan vendor:publish --provider="Buzz\LaravelHCaptcha\CaptchaServiceProvider"