Skip to content

Instantly share code, notes, and snippets.

@ivanvermeyen
Created July 16, 2016 12:38
Show Gist options
  • Save ivanvermeyen/2e3a2f1ee750d21576dca3172074dc6b to your computer and use it in GitHub Desktop.
Save ivanvermeyen/2e3a2f1ee750d21576dca3172074dc6b to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class SomeRequest extends FormRequest
{
/**
* Validate conditional rules.
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function getValidatorInstance()
{
$validator = parent::getValidatorInstance();
$validator->sometimes('g-recaptcha-response', 'required|captcha', function ($input) {
return ! app()->environment('testing');
});
return $validator;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment