parseCustomFields($data['custom_fields']); } $company->fill($data); if (array_key_exists('settings', $data)) { $company->saveSettings($data['settings'], $company); } $company->save(); return $company; } private function parseCustomFields($fields) :array { foreach ($fields as &$value) { $value = (string)$value; } return $fields; } }