I am newbie in Laravel. I've used this recaptcha package: https://github.com/greggilbert/recaptcha And the documentation saids that: In your validation rules, add the following:
$rules = array(
// ...
'g-recaptcha-response' => 'required|recaptcha',
};
By the way I use the laravel 5's Registrar:
<?php namespace taxman\Services;
use taxman\User;
use Validator;
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
class Registrar implements RegistrarContract {
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
public function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:4',
'telephone' => 'required',
'g-recaptcha-response' => 'required|recaptcha',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
But in this case the laravel return with a error message: "The g-recaptcha-response is required", however in the view I used this command:
<div class="form-group">
{!! Recaptcha::render() !!}
</div>
And yes, the field is not empty!
So, I think, I should put the 'g-recaptcha-response' => 'required|recaptcha'
somewhere else?
Because it seems, in the Registrar's validator does not work.
if someone is still pulling their hair because of this issue just remove the 'recaptcha'
in validation rule.
use
'g-recaptcha-response' => 'required'
instead of
'g-recaptcha-response' => 'required|recaptcha'
see http://tuts.codingo.me/google-recaptcha-in-laravel-application/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With