From d87a199a42afcf085429f02a76aafac440de671a Mon Sep 17 00:00:00 2001 From: Robin Lidbetter Date: Thu, 14 Sep 2017 15:40:47 -0400 Subject: [PATCH] move validated request input extraction into its own method --- .../Foundation/Validation/ValidatesRequests.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Validation/ValidatesRequests.php b/src/Illuminate/Foundation/Validation/ValidatesRequests.php index 2f1a63227f1e..830da1036290 100644 --- a/src/Illuminate/Foundation/Validation/ValidatesRequests.php +++ b/src/Illuminate/Foundation/Validation/ValidatesRequests.php @@ -25,9 +25,7 @@ public function validateWith($validator, Request $request = null) $validator->validate(); - return $request->only(collect($validator->getRules())->keys()->map(function ($rule) { - return str_contains($rule, '.') ? explode('.', $rule)[0] : $rule; - })->unique()->toArray()); + return $this->extractInputFromRules($request, $validator->getRules()); } /** @@ -46,6 +44,18 @@ public function validate(Request $request, array $rules, ->make($request->all(), $rules, $messages, $customAttributes) ->validate(); + return $this->extractInputFromRules($request, $rules); + } + + /** + * Get request inputs using validator rules. + * + * @param \Illuminate\Http\Request $request + * @param array $rules + * @return array + */ + protected function extractInputFromRules(Request $request, $rules) + { return $request->only(collect($rules)->keys()->map(function ($rule) { return str_contains($rule, '.') ? explode('.', $rule)[0] : $rule; })->unique()->toArray());