Skip to content

Commit fd5dbfb

Browse files
Make rules method in FormRequest optional (#6228)
Co-authored-by: 李铭昕 <[email protected]>
1 parent 4d2d9ed commit fd5dbfb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Request/FormRequest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public function setContainer(ContainerInterface $container): static
104104
return $this;
105105
}
106106

107+
public function rules(): array
108+
{
109+
return [];
110+
}
111+
107112
/**
108113
* Get the validator instance for the request.
109114
*/
@@ -198,7 +203,7 @@ protected function getContextValidatorKey(string $key): string
198203
*/
199204
protected function getRules(): array
200205
{
201-
$rules = call_user_func_array([$this, 'rules'], []);
206+
$rules = $this->rules();
202207
$scene = $this->getScene();
203208
if ($scene && isset($this->scenes[$scene]) && is_array($this->scenes[$scene])) {
204209
return Arr::only($rules, $this->scenes[$scene]);

0 commit comments

Comments
 (0)