Only override fieldset_id with custom_fieldset_id if it’s present

This is mostly to support prior versions. I have NFC why we did this in the first place. I’m sure I had a stellar reason, but couldn’t tell you what it is today.

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2020-04-30 20:59:42 -07:00
parent e9cb17394c
commit 85712a1960
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -154,7 +154,19 @@ class AssetModelsController extends Controller
$this->authorize('update', AssetModel::class);
$assetmodel = AssetModel::findOrFail($id);
$assetmodel->fill($request->all());
$assetmodel->fieldset_id = $request->get("custom_fieldset_id");
/**
* Allow custom_fieldset_id to override and populate fieldset_id.
* This is stupid, but required for legacy API support.
*
* I have no idea why we manually overrode that field name
* in previous versions. I assume there was a good reason for
* it, but I'll be damned if I can think of one. - snipe
*/
if ($request->filled('custom_fieldset_id')) {
$assetmodel->fieldset_id = $request->get("custom_fieldset_id");
}
if ($assetmodel->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $assetmodel, trans('admin/models/message.update.success')));