From 84078358ce32ff0656a9ab03f062e952f721f1a2 Mon Sep 17 00:00:00 2001 From: Shalvah Date: Sat, 26 Aug 2023 17:48:14 +0200 Subject: [PATCH] Support injecting deps in FormRequest rules() --- src/Extracting/Strategies/GetFromFormRequestBase.php | 4 ++-- tests/Fixtures/TestRequestQueryParams.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Extracting/Strategies/GetFromFormRequestBase.php b/src/Extracting/Strategies/GetFromFormRequestBase.php index 214d12a8..b1f68d0a 100644 --- a/src/Extracting/Strategies/GetFromFormRequestBase.php +++ b/src/Extracting/Strategies/GetFromFormRequestBase.php @@ -68,10 +68,10 @@ protected function getRouteValidationRules($formRequest) if (method_exists($formRequest, 'validator')) { $validationFactory = app(ValidationFactory::class); - return call_user_func_array([$formRequest, 'validator'], [$validationFactory]) + return app()->call([$formRequest, 'validator'], [$validationFactory]) ->getRules(); } elseif (method_exists($formRequest, 'rules')) { - return call_user_func_array([$formRequest, 'rules'], []); + return app()->call([$formRequest, 'rules']); } return []; diff --git a/tests/Fixtures/TestRequestQueryParams.php b/tests/Fixtures/TestRequestQueryParams.php index b9131656..4b9d2e2f 100644 --- a/tests/Fixtures/TestRequestQueryParams.php +++ b/tests/Fixtures/TestRequestQueryParams.php @@ -6,7 +6,7 @@ class TestRequestQueryParams extends FormRequest { - public function rules() + public function rules(\stdClass $injectedDep) { return [ 'q_param' => 'int|required',