PHP code example of vvb / yandex-smart-captcha

1. Go to this page and download the library: Download vvb/yandex-smart-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/ */

    

vvb / yandex-smart-captcha example snippets


use vvb\YandexSmartCaptcha\Rules\YandexSmartCaptchaRule;

public function store(Request $request)
{
    $request->validate([
        'smart-token' => [new YandexSmartCaptchaRule],
    ]);
    
    // Ваша логика
}

new YandexSmartCaptchaRule(
    message: 'Неверная капча!',
    emptyMessage: 'Пожалуйста, пройдите проверку'
)

return [
    'yandex_smart_captcha_rule' => 'Капча не пройдена',
    'yandex_smart_captcha_empty' => 'Требуется подтверждение капчи',
];

use Illuminate\Http\Request;
use vvb\YandexSmartCaptcha\Rules\YandexSmartCaptchaRule;

class FormController extends Controller
{
    public function showForm()
    {
        return view('form');
    }

    public function submitForm(Request $request)
    {
        $request->validate([
            'email' => '->with('success', 'Форма успешно отправлена!');
    }
}
bash
php artisan vendor:publish --tag=config --provider="vvb\YandexSmartCaptcha\YandexSmartCaptchaServiceProvider"