Tweak 'exist' rule in Asset->model_id field so it ignores soft-deleted models

This commit is contained in:
Ivan Nieto Vivanco 2023-05-04 03:12:36 -06:00
parent 4efa84270a
commit fbb7c55450
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',