Method Illuminate\Validation\Validator::validateCaptcha does not exist

Viewed 595

I am using Laravel and I did not add any code yet but I tried integrating recaptcha into laravel's auth package. I have put the script and the recaptcha shows up at the form already. I also put validation so that the recaptcha is required. However, when I submit the form with recaptcha it throws that error. Here is my register controller from auth package:

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        'password' => ['required', 'string', 'min:8', 'confirmed'],
        'g-recaptcha-response' => ['required|captcha']
    ]);
}
1 Answers

I was having the same problem, Oddly it was working fine locally, but in production not.

In my case, using https://github.com/anhskohbo/no-captcha , I had to add:

Anhskohbo\NoCaptcha\NoCaptchaServiceProvider::class,

In the providers array in:

app/config/app.php

for it to work in production. ( step one in the README from that repo ) and since I completed step one I also completed step 2. Using Laravel 9.

I have no idea why locally, or in my other server it was working ok but not in a specific client's server..

Related