File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1111use function app ;
1212use function array_diff ;
1313use function array_keys ;
14+ use function array_search ;
1415use function config ;
1516use function in_array ;
1617use function method_exists ;
2223trait RestrictsExtraAttributes
2324{
2425 protected bool $ checkForExtraProperties = true ;
26+ protected array $ ignoreExtraProperties = [];
2527 protected bool $ checkForEmptyPayload = true ;
2628 protected array $ methodsForEmptyPayload = ['PATCH ' , 'POST ' , 'PUT ' ];
2729
@@ -53,8 +55,19 @@ private function checkForNotAllowedProperties(): void
5355 return ;
5456 }
5557
58+ $ validationData = $ this ->getValidationData ();
59+
60+ // Ignore marked properties
61+ if (! empty ($ this ->ignoreExtraProperties )) {
62+ foreach ($ this ->ignoreExtraProperties as $ deleleValue ) {
63+ if (($ key = array_search ($ deleleValue , $ validationData )) !== false ) {
64+ unset($ validationData [$ key ]);
65+ }
66+ }
67+ }
68+
5669 $ extraAttributes = array_diff (
57- $ this -> getValidationData () ,
70+ $ validationData ,
5871 $ this ->getAllowedAttributes (),
5972 );
6073
You can’t perform that action at this time.
0 commit comments