Decrypt encrypted fields

This commit is contained in:
snipe 2017-07-08 17:04:40 -07:00
parent 20376daec4
commit 635299cd74

View file

@ -79,6 +79,37 @@ class AssetsTransformer
'user_can_checkout' => (bool) $asset->availableForCheckout(),
];
if ($asset->model->fieldset) {
$fields_array = array();
foreach ($asset->model->fieldset->fields as $field) {
if ($field->isFieldDecryptable($asset->{$field->convertUnicodeDbSlug()})) {
$decrypted = \App\Helpers\Helper::gracefulDecrypt($field,$asset->{$field->convertUnicodeDbSlug()});
$value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));
$fields_array = [$field->convertUnicodeDbSlug() => $value];
// $fields_array[$field->name] = [
// 'field' => $field->convertUnicodeDbSlug(),
// 'value' => $value
// ];
} else {
// $fields_array[$field->name] = [
// 'field' => $field->convertUnicodeDbSlug(),
// 'value' => $asset->{$field->convertUnicodeDbSlug()}
// ];
$fields_array = [$field->convertUnicodeDbSlug() => $asset->{$field->convertUnicodeDbSlug()}];
}
$array += $fields_array;
//$array['custom_fields'] = $fields_array;
}
}
$permissions_array['available_actions'] = [
'checkout' => (bool) Gate::allows('checkout', Asset::class),
'checkin' => (bool) Gate::allows('checkin', Asset::class),
@ -88,14 +119,6 @@ class AssetsTransformer
];
$array += $permissions_array;
if ($asset->model->fieldset) {
foreach ($asset->model->fieldset->fields as $field) {
$fields_array = [$field->name => $asset->{$field->convertUnicodeDbSlug()}];
$array += $fields_array;
}
}
return $array;
}