Skip to content

Commit

Permalink
catch custom fields that are arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerrlongg committed Oct 18, 2023
1 parent 74ed329 commit 388e4c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ public function selectlist(Request $request)
* @author [A. Gianotto] [<[email protected]>]
* @param \App\Http\Requests\ImageUploadRequest $request
* @since [v4.0]
* @return JsonResponse
*/
public function store(ImageUploadRequest $request)
{
Expand Down Expand Up @@ -579,6 +578,10 @@ public function store(ImageUploadRequest $request)

if (($model) && ($model->fieldset)) {
foreach ($model->fieldset->fields as $field) {
//reduce "array to string conversion" exceptions - ideally we'd handle this in a form request, but this works for now
if(is_array($request->input($field->db_column, null))) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'This custom field can not be an array', 200));
}

// Set the field value based on what was sent in the request
$field_val = $request->input($field->db_column, null);
Expand Down
4 changes: 0 additions & 4 deletions app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ public function save(array $params = [])
}
}

if (!is_array($params)){
return false;
}

return parent::save($params);
}

Expand Down

0 comments on commit 388e4c1

Please sign in to comment.