From 704209de9c7a0c0eb484effa286454cae8213a3d Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Thu, 11 Oct 2018 19:15:09 -0500 Subject: [PATCH] Fixed #6301: Do not allow duplicate asset tags (#6324) * Fixed #6301: Do not allow duplicate asset tags * Display error message for single asset_tag failure --- app/Http/Controllers/Assets/AssetsController.php | 4 ++-- resources/views/hardware/edit.blade.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 5dbb279673..273c905008 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -171,8 +171,8 @@ class AssetsController extends Controller } } - // Was the asset created? - if ($asset->save()) { + // Validate the asset before saving + if ($asset->isValid() && $asset->save()) { if (request('assigned_user')) { $target = User::find(request('assigned_user')); diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 24e87bbec8..6f077d134e 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -35,6 +35,7 @@ @endif {!! $errors->first('asset_tags', ' :message') !!} + {!! $errors->first('asset_tag', ' :message') !!} @include ('partials.forms.edit.serial', ['fieldname'=> 'serials[1]', 'translated_serial' => trans('admin/hardware/form.serial')])