From e4ff5463f9031d901040318ba8e9ea70263f0818 Mon Sep 17 00:00:00 2001 From: crynobone Date: Mon, 26 May 2014 16:46:22 +0800 Subject: [PATCH] Add Orchestra\Support\Traits\ValidationTrait::getValidationSchemasName()`. Signed-off-by: crynobone --- src/Support/Traits/ValidationTrait.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Support/Traits/ValidationTrait.php b/src/Support/Traits/ValidationTrait.php index 508c3f1..7d2ead1 100644 --- a/src/Support/Traits/ValidationTrait.php +++ b/src/Support/Traits/ValidationTrait.php @@ -31,8 +31,7 @@ trait ValidationTrait */ public function onValidationScenario($scenario, array $parameters = []) { - $on = 'on'.ucfirst($scenario); - $extend = 'extend'.ucfirst($scenario); + list($on, $extend) = $this->getValidationSchemasName($scenario); $this->validationScenarios = [ 'on' => method_exists($this, $on) ? $on : null, @@ -182,4 +181,18 @@ public function getValidationRules() { return []; } + + /** + * Get validation schemas name. + * + * @param string $scenario + * @return array + */ + protected function getValidationSchemasName($scenario) + { + $on = 'on'.ucfirst($scenario); + $extend = 'extend'.ucfirst($scenario); + + return [$on, $extend]; + } }