From 66e94dd7c04b369b958236a8eac0302384075b26 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 12 Mar 2017 18:31:56 -0400 Subject: [PATCH] combine validation --- app/Repositories/OptionRepository.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/Repositories/OptionRepository.php b/app/Repositories/OptionRepository.php index b5e9510c1..80a0a52a7 100644 --- a/app/Repositories/OptionRepository.php +++ b/app/Repositories/OptionRepository.php @@ -130,7 +130,9 @@ class OptionRepository 'config_from' => 'sometimes|required|numeric|exists:service_options,id', ]); - $validator->sometimes('config_startup', 'required_without:config_from|json', function ($input) use ($option) { + $validator->sometimes([ + 'config_startup', 'config_logs', 'config_files', + ], 'required_without:config_from|json', function ($input) use ($option) { return ! (! $input->config_from && ! is_null($option->config_from)); }); @@ -138,14 +140,6 @@ class OptionRepository return ! (! $input->config_from && ! is_null($option->config_from)); }); - $validator->sometimes('config_logs', 'required_without:config_from|json', function ($input) use ($option) { - return ! (! $input->config_from && ! is_null($option->config_from)); - }); - - $validator->sometimes('config_files', 'required_without:config_from|json', function ($input) use ($option) { - return ! (! $input->config_from && ! is_null($option->config_from)); - }); - if ($validator->fails()) { throw new DisplayValidationException($validator->errors()); }