Merge pull request #12976 from inietov/fixes/validate_soft-deleted_models_in_asset_model

Refactor of #12955
This commit is contained in:
snipe 2023-05-08 13:14:02 -07:00 committed by GitHub
commit 6486ea4fb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 4 deletions

View file

@ -573,9 +573,6 @@ 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) {

View file

@ -90,7 +90,7 @@ class Asset extends Depreciable
protected $rules = [
'name' => 'max:255|nullable',
'model_id' => 'required|integer|exists:models,id',
'model_id' => 'required|integer|exists:models,id,deleted_at,NULL',
'status_id' => 'required|integer|exists:status_labels,id',
'company_id' => 'integer|nullable',
'warranty_months' => 'numeric|nullable|digits_between:0,240',