mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Merge pull request #14055 from snipe/bug/disallow_arrays_for_model_id_in_api_hardware_update
Make sure we're getting an object instead of a collection on Asset API for model_id
This commit is contained in:
commit
fe51d0ef79
|
@ -574,10 +574,11 @@ class AssetsController extends Controller
|
||||||
$asset = $request->handleImages($asset);
|
$asset = $request->handleImages($asset);
|
||||||
|
|
||||||
// Update custom fields in the database.
|
// Update custom fields in the database.
|
||||||
// Validation for these fields is handled through the AssetRequest form request
|
$model = AssetModel::find($request->input('model_id'));
|
||||||
$model = AssetModel::find($request->get('model_id'));
|
|
||||||
|
|
||||||
if (($model) && ($model->fieldset)) {
|
// Check that it's an object and not a collection
|
||||||
|
// (Sometimes people send arrays here and they shouldn't
|
||||||
|
if (($model) && ($model instanceof AssetModel) && ($model->fieldset)) {
|
||||||
foreach ($model->fieldset->fields as $field) {
|
foreach ($model->fieldset->fields as $field) {
|
||||||
|
|
||||||
// Set the field value based on what was sent in the request
|
// Set the field value based on what was sent in the request
|
||||||
|
|
Loading…
Reference in a new issue