To add Captcha to Laravel form without any API Connection
Install mews/captcha
composer require mews/captcha
Find the providers key in config/app.php and register the Captcha Service Provider. for for Laravel 5.1+
'providers' => [
        // ...
        Mews\Captcha\CaptchaServiceProvider::class,
    ]
Find the aliases key in config/app.php.
'aliases' => [
        // ...
        'Captcha' => Mews\Captcha\Facades\Captcha::class,
    ]
publish mews/captcha by running - 
$ php artisan vendor:publish
Add this to .env to disable captcha
CAPTCHA_DISABLE=true
Add this on laravel blade
 //register.blade.php
    <img src="{{ captcha_src() }}" alt="captcha">
        <div class="mt-2"></div>
        <input 
            type="text" name="captcha" class="form-control @error('captcha') is-invalid @enderror" placeholder="Please Insert Captch"
            >
         @error('captcha') 
         <div class="invalid-feedback">{{ $message }}</div> @enderror 
in controller validate like this -
$request->validate([
'captcha' => 'required|captcha'
],[],[
     'captcha.required' => 'Captcha is required',
     'captcha.captcha' => 'Captcha is invalid',
])
 
 
              

 
    
Top comments (0)