This content originally appeared on DEV Community and was authored by Arman Rahman
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',
])
This content originally appeared on DEV Community and was authored by Arman Rahman
Arman Rahman | Sciencx (2024-08-25T04:40:56+00:00) Add Captcha On Laravel Forms. Retrieved from https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.