Check if model exists before create asset via API

This commit is contained in:
Ivan Nieto Vivanco 2023-05-01 16:05:03 -06:00
parent 031c9c1204
commit 1b2d830380

View file

@ -573,6 +573,10 @@ class AssetsController extends Controller
// Update custom fields in the database.
// Validation for these fields is handled through the AssetRequest form request
$model = AssetModel::find($request->get('model_id'));
if (!$model) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/models/message.does_not_exist')), 200);
}
if (($model) && ($model->fieldset)) {
foreach ($model->fieldset->fields as $field) {