Skip to content

Commit

Permalink
store good, update needs work
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerrlongg committed Feb 22, 2024
1 parent d67ff54 commit 20dbacd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,16 @@ public function store(StoreAssetRequest $request): JsonResponse
}
}
if ($field->element == 'checkbox') {
if ($field->field_encrypted) {
// to not break a bunch of stuff, we must decrypt + implode if the checkbox value is an array
$field_val_decrypt = Crypt::decrypt($field_val);
if (is_array($field_val_decrypt)) {
$field_val_decrypt_imploded = implode(',', $field_val_decrypt);
$field_val = Crypt::encrypt($field_val_decrypt_imploded);
} else
$field_val = Crypt::encrypt($field_val_decrypt);

}
if(is_array($field_val)) {
$field_val = implode(',', $field_val);
}
Expand Down Expand Up @@ -665,6 +675,16 @@ public function update(ImageUploadRequest $request, $id)
}
}
if ($field->element == 'checkbox') {
//if ($field->field_encrypted) {
// // to not break a bunch of stuff, we must decrypt + implode if the checkbox value is an array
// $field_val_decrypt = Crypt::decrypt($field_val);
// if (is_array($field_val_decrypt)) {
// $field_val_decrypt_imploded = implode(',', $field_val_decrypt);
// $field_val = Crypt::encrypt($field_val_decrypt_imploded);
// } else
// $field_val = Crypt::encrypt($field_val_decrypt);
//
//}
if(is_array($field_val)) {
$field_val = implode(',', $field_val);
$asset->{$field->db_column} = $field_val;
Expand Down

0 comments on commit 20dbacd

Please sign in to comment.