@@ -215,7 +215,7 @@ protected function getSummaryColumns()
215
215
}
216
216
217
217
/**
218
- * Override to control the columns returned in GET requests
218
+ * Override to control the columns exposed by the rest resource (output in GET requests, accepted via PUT/POST)
219
219
*
220
220
* @return string[]
221
221
*/
@@ -347,7 +347,7 @@ public function put($restResource)
347
347
{
348
348
try {
349
349
$ model = $ this ->getModel ();
350
- $ model -> importData ( $ restResource );
350
+ $ this -> importModelData ( $ model , $ restResource );
351
351
352
352
$ this ->beforeModelUpdated ($ model , $ restResource );
353
353
@@ -613,7 +613,7 @@ public function post($restResource)
613
613
$ newModel = SolutionSchema::getModel ($ this ->getModelName ());
614
614
615
615
if (is_array ($ restResource )) {
616
- $ newModel -> importData ( $ restResource );
616
+ $ this -> importModelData ( $ newModel , $ restResource );
617
617
}
618
618
$ this ->beforeModelCreated ($ newModel , $ restResource );
619
619
@@ -653,6 +653,15 @@ protected function beforeModelCreated($model, $restResource)
653
653
654
654
}
655
655
656
+ /**
657
+ * @param Model $model
658
+ * @param array $modelData
659
+ */
660
+ protected function importModelData ($ model , $ modelData )
661
+ {
662
+ $ model ->importData (array_intersect_key ($ modelData , array_flip ($ this ->getColumns ())));
663
+ }
664
+
656
665
/**
657
666
* Returns the ItemRestResource for the $resourceIdentifier contained in this collection.
658
667
*
0 commit comments