File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change 14
14
use Hyperf \Context \Context ;
15
15
use Hyperf \Contract \ValidatorInterface ;
16
16
use Hyperf \HttpServer \Request ;
17
+ use Hyperf \Utils \Arr ;
17
18
use Hyperf \Validation \Contract \ValidatesWhenResolved ;
18
19
use Hyperf \Validation \Contract \ValidatorFactoryInterface as ValidationFactory ;
19
20
use Hyperf \Validation \UnauthorizedException ;
@@ -200,13 +201,7 @@ protected function getRules(): array
200
201
$ rules = call_user_func_array ([$ this , 'rules ' ], []);
201
202
$ scene = $ this ->getScene ();
202
203
if ($ scene && isset ($ this ->scenes [$ scene ]) && is_array ($ this ->scenes [$ scene ])) {
203
- $ newRules = [];
204
- foreach ($ this ->scenes [$ scene ] as $ field ) {
205
- if (array_key_exists ($ field , $ rules )) {
206
- $ newRules [$ field ] = $ rules [$ field ];
207
- }
208
- }
209
- return $ newRules ;
204
+ return Arr::only ($ rules , $ this ->scenes [$ scene ]);
210
205
}
211
206
return $ rules ;
212
207
}
You can’t perform that action at this time.
0 commit comments