Extracts some logic into resuable methods

This commit is contained in:
Vlad
2017-05-14 12:07:07 -04:00
parent bd39c34f03
commit 3a1bf88c22
4 changed files with 62 additions and 20 deletions

View File

@@ -148,4 +148,15 @@ class CustomField extends Model {
return $custom_field->save();
}
static function extractCustomFieldsFromFromObject($data) {
$custom_fields = array();
foreach($data as $key => $value) {
if(strpos($key, 'cf_') === 0) {
$custom_fields[(int)substr($key, 3)] = $value;
unset($data[$key]);
}
}
return array($data, $custom_fields);
}
}