Skip to content

Commit

Permalink
this seems to work for patches
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerrlongg committed Feb 20, 2024
1 parent c6d85a1 commit 26728a8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public function store(StoreAssetRequest $request): JsonResponse
$model = AssetModel::find($request->input('model_id'));

// Check that it's an object and not a collection
// (Sometimes people send arrays here and they shouldn't
// (Sometimes people send arrays here and they shouldn't, unless it's a checkbox)
if (($model) && ($model instanceof AssetModel) && ($model->fieldset)) {
foreach ($model->fieldset->fields as $field) {

Expand Down Expand Up @@ -657,18 +657,21 @@ public function update(ImageUploadRequest $request, $id)
// Update custom fields
if (($model) && (isset($model->fieldset))) {
foreach ($model->fieldset->fields as $field) {
$field_val = $request->input($field->db_column, null);
if ($request->has($field->db_column)) {
if ($field->field_encrypted == '1') {
if (Gate::allows('admin')) {
$asset->{$field->db_column} = \Crypt::encrypt($request->input($field->db_column));
$asset->{$field->db_column} = Crypt::encrypt($field_val);
}
} else {
if ($field->element == 'checkbox') {
if(is_array($field_val)) {
$field_val = implode(',', $field_val);
}
}
if ($field->element == 'checkbox') {
if(is_array($field_val)) {
$field_val = implode(',', $field_val);
$asset->{$field->db_column} = $field_val;
}
$asset->{$field->db_column} = $request->input($field->db_column);
}
else {
$asset->{$field->db_column} = $field_val;
}
}
}
Expand Down

0 comments on commit 26728a8

Please sign in to comment.