Skip to content

Commit

Permalink
Support injecting deps in FormRequest rules()
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Aug 26, 2023
1 parent 4960403 commit 8407835
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Extracting/Strategies/GetFromFormRequestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestRequestQueryParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestRequestQueryParams extends FormRequest
{
public function rules()
public function rules(\stdClass $injectedDep)
{
return [
'q_param' => 'int|required',
Expand Down

0 comments on commit 8407835

Please sign in to comment.