factory = $validator; $this->field = $config->get('jsvalidation.remote_validation_field'); $this->escape = (bool) $config->get('jsvalidation.escape', false); } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { if ($request->has($this->field)) { $this->wrapValidator(); } return $next($request); } /** * Wraps Validator resolver with RemoteValidator resolver. * * @return void */ protected function wrapValidator() { $resolver = new Resolver($this->factory, $this->escape); $this->factory->resolver($resolver->resolver($this->field)); $this->factory->extend(RemoteValidator::EXTENSION_NAME, $resolver->validatorClosure()); } }