Added comments

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2025-04-08 02:24:33 +01:00
parent 4b21f0d00b
commit c4d0afb8d4

View File

@@ -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