A free open source IT asset/license management system
Added comments
snipec4d0afb8d4bf
diff --git a/app/Http/Requests/Traits/MayContainCustomFields.php b/app/Http/Requests/Traits/MayContainCustomFields.phpindex da079c56d2..9fd09d507d 100644--- a/app/Http/Requests/Traits/MayContainCustomFields.php+++ b/app/Http/Requests/Traits/MayContainCustomFields.php@@ -13,17 +13,26 @@ trait MayContainCustomFields// For auditing and some other non-standard things where $this is only the form submission and may not have the asset info- if ((request()->route('asset') && (request()->route('asset')->model_id))) {- $asset_model = AssetModel::find(request()->route('asset')->model_id);- } else {- // find the model- if ($this->method() == 'POST') {- $asset_model = AssetModel::find($this->model_id);- }- if ($this->method() == 'PATCH' || $this->method() == 'PUT') {- $asset_model = $this->asset->model;- }- }+ // In case the model is being changed+ if (request()->input('model_id')->model_id!='') {++ $asset_model = AssetModel::find(request()->route('asset')->model_id);++ // or if we have it available to route-model-binding+ } elseif ((request()->route('asset') && (request()->route('asset')->model_id))) {++ $asset_model = AssetModel::find(request()->route('asset')->model_id);++ } else {++ if ($this->method() == 'POST') {+ $asset_model = AssetModel::find($this->model_id);+ }++ if ($this->method() == 'PATCH' || $this->method() == 'PUT') {+ $asset_model = $this->asset->model;+ }+ }// collect the custom fields in the request