A free open source IT asset/license management system
backend form validation. +cleanup
akemidxd262638a63af
diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.phpindex f84a468a60..2c49f78bfb 100644--- a/app/Http/Controllers/Assets/AssetCheckinController.php+++ b/app/Http/Controllers/Assets/AssetCheckinController.php@@ -116,6 +116,12 @@ class AssetCheckinController extends Controller$seat->update(['assigned_to' => null]);});+ $settings = \App\Models\Setting::getSettings();++ if($settings->require_checkinout_notes=="1" && (is_null($request->note))) {+ return redirect()->to("hardware/$assetId/checkin")->with('error', trans('admin/hardware/message.update.no_note'));+ }+// Get all pending Acceptances for this asset and delete them$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',[Asset::class],diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.phpindex 05b766916b..506f47680c 100644--- a/app/Http/Controllers/Assets/AssetCheckoutController.php+++ b/app/Http/Controllers/Assets/AssetCheckoutController.php@@ -102,6 +102,10 @@ class AssetCheckoutController extends Controller$settings = \App\Models\Setting::getSettings();+ if($settings->require_checkinout_notes=="1" && (is_null($request->note))) {+ return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.update.no_note'); //needs translation+ }+// We have to check whether $target->company_id is null here since locations don't have a company yetif (($settings->full_multiple_companies_support) && ((!is_null($target->company_id)) && (!is_null($asset->company_id)))) {if ($target->company_id != $asset->company_id){diff --git a/app/Http/Requests/AssetCheckinRequest.php b/app/Http/Requests/AssetCheckinRequest.phpindex 3bee83a810..ea28471899 100644--- a/app/Http/Requests/AssetCheckinRequest.php+++ b/app/Http/Requests/AssetCheckinRequest.php@@ -14,18 +14,6 @@ class AssetCheckinRequest extends Requestreturn true;}- /**- * Get the validation rules that apply to the request.- *- * @return array- */-// public function rules()-// {-// 'note' => 'required|in:asset,',-//-// return $rules;-// }-public function response(array $errors){return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);diff --git a/app/Http/Requests/AssetCheckoutRequest.php b/app/Http/Requests/AssetCheckoutRequest.phpindex 9064e6dcd0..f48a7d5e53 100644--- a/app/Http/Requests/AssetCheckoutRequest.php+++ b/app/Http/Requests/AssetCheckoutRequest.php@@ -27,7 +27,6 @@ class AssetCheckoutRequest extends Request'assigned_location' => 'required_without_all:assigned_user,assigned_asset','status_id' => 'exists:status_labels,id,deployable,1','checkout_to_type' => 'required|in:asset,location,user',-// 'note' => 'required|in:asset,','checkout_at' => ['nullable','date',diff --git a/resources/lang/en-US/admin/hardware/message.php b/resources/lang/en-US/admin/hardware/message.phpindex d06bf4a0e0..c9ea79023b 100644--- a/resources/lang/en-US/admin/hardware/message.php+++ b/resources/lang/en-US/admin/hardware/message.php@@ -23,6 +23,7 @@ return ['nothing_updated' => 'No fields were selected, so nothing was updated.','no_assets_selected' => 'No assets were selected, so nothing was updated.','assets_do_not_exist_or_are_invalid' => 'Selected assets cannot be updated.',+ 'no_note' => 'Note field is empty',],'restore' => [@@ -76,6 +77,7 @@ return ['user_does_not_exist' => 'That user is invalid. Please try again.','not_available' => 'That asset is not available for checkout!','no_assets_selected' => 'You must select at least one asset from the list',+],'checkin' => [diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.phpindex 12c678e645..c015b25631 100755--- a/resources/views/hardware/checkin.blade.php+++ b/resources/views/hardware/checkin.blade.php@@ -124,6 +124,7 @@name="note">{{ old('note', $asset->note) }}</textarea>{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}</div>+ @endif</div></div> <!--/.box-body--></div> <!--/.box-body-->