Merge pull request #11272 from inietov/fixes/date_localization_in_customfields

Fixes #8143 Date localization not working on custom fields
This commit is contained in:
snipe 2022-06-13 19:47:20 -07:00 committed by GitHub
commit 20a0c4e3b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -98,6 +98,14 @@ class AssetsTransformer
$decrypted = Helper::gracefulDecrypt($field, $asset->{$field->convertUnicodeDbSlug()});
$value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));
if ($field->format == 'DATE'){
if (Gate::allows('superadmin')){
$value = Helper::getFormattedDateObject($value)['formatted'];
} else {
$value = strtoupper(trans('admin/custom_fields/general.encrypted'));
}
}
$fields_array[$field->name] = [
'field' => e($field->convertUnicodeDbSlug()),
'value' => e($value),
@ -107,15 +115,19 @@ class AssetsTransformer
];
} else {
$value = $asset->{$field->convertUnicodeDbSlug()};
if ($field->format == 'DATE'){
$value = Helper::getFormattedDateObject($value)['formatted'];
}
$fields_array[$field->name] = [
'field' => e($field->convertUnicodeDbSlug()),
'value' => e($asset->{$field->convertUnicodeDbSlug()}),
'value' => e($value),
'field_format' => $field->format,
'element' => $field->element,
];
}
$array['custom_fields'] = $fields_array;
}
} else {