Skip to content

Commit

Permalink
Allow to hook into the validator instance from the FormRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
shadoWalker89 committed Oct 14, 2016
1 parent 90621eb commit 7821b5a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Illuminate/Foundation/Http/FormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ protected function getValidatorInstance()
$factory = $this->container->make(ValidationFactory::class);

if (method_exists($this, 'validator')) {
return $this->container->call([$this, 'validator'], compact('factory'));
$validator = $this->container->call([$this, 'validator'], compact('factory'));
} else {
$validator = $factory->make(
$this->validationData(), $this->container->call([$this, 'rules']), $this->messages(), $this->attributes()
);
}

return $factory->make(
$this->validationData(), $this->container->call([$this, 'rules']), $this->messages(), $this->attributes()
);
if (method_exists($this, 'validatorHooks')) {
$this->validatorHooks($validator);
}

return $validator;
}

/**
Expand Down

0 comments on commit 7821b5a

Please sign in to comment.