Skip to content

DevWizardHQ/wiz-captcha

Repository files navigation

This is my package wiz-captcha

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require devwizardhq/wiz-captcha

You can publish the config file with:

php artisan vendor:publish --tag="wiz-captcha-config"

Usage

In View

<form method="POST" action="/contact">
    @csrf

    {!! wiz_captcha_img('default', ['id' => 'captcha-image']) !!}

    <button type="button" onclick="refreshCaptcha()">Refresh</button>

    <input type="text" name="captcha" required autocomplete="off">

    @error('captcha')
        <div>{{ $message }}</div>
    @enderror

    <button type="submit">Submit</button>
</form>

<script>
function refreshCaptcha() {
    document.getElementById('captcha-image').src = "{{ route('wiz-captcha.image') }}?" + Date.now();
}
</script>

Controller

use DevWizardHQ\Captcha\Rules\CaptchaRule;

$request->validate([
    'captcha' => ['required', new CaptchaRule],
]);

String Rule

$request->validate([
    'captcha' => ['required', 'wiz_captcha'],
]);

API Rule

$captcha = wiz_captcha_api('math');

API Validation

use DevWizardHQ\Captcha\Rules\CaptchaApiRule;

$request->validate([
    'captcha_key' => ['required', 'string'],
    'captcha' => ['required', new CaptchaApiRule($request->captcha_key)],
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

laravel captcha package.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages