diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php index 627045acdb..d99e570810 100644 --- a/app/Http/Transformers/ActionlogsTransformer.php +++ b/app/Http/Transformers/ActionlogsTransformer.php @@ -6,6 +6,7 @@ use App\Models\Actionlog; use App\Models\Asset; use App\Models\CustomField; use App\Models\Setting; +use App\Models\Statuslabel; use App\Models\Company; use App\Models\Supplier; use App\Models\Location; @@ -215,6 +216,7 @@ class ActionlogsTransformer { $location = Location::withTrashed()->get(); $supplier = Supplier::withTrashed()->get(); $model = AssetModel::withTrashed()->get(); + $status = Statuslabel::withTrashed()->get(); $company = Company::get(); @@ -288,6 +290,19 @@ class ActionlogsTransformer $clean_meta['Supplier'] = $clean_meta['supplier_id']; unset($clean_meta['supplier_id']); } + if(array_key_exists('status_id', $clean_meta)) { + + $oldStatus = $status->find($clean_meta['status_id']['old']); + $oldStatusName = $oldStatus ? e($oldStatus->name) : trans('admin/statuslabels/message.deleted_label'); + + $newStatus = $status->find($clean_meta['status_id']['new']); + $newStatusName = $newStatus ? e($newStatus->name) : trans('admin/statuslabels/message.deleted_label'); + + $clean_meta['status_id']['old'] = $clean_meta['status_id']['old'] ? "[id: ".$clean_meta['status_id']['old']."] ". $oldStatusName : trans('general.unassigned'); + $clean_meta['status_id']['new'] = $clean_meta['status_id']['new'] ? "[id: ".$clean_meta['status_id']['new']."] ". $newStatusName : trans('general.unassigned'); + $clean_meta['Status'] = $clean_meta['status_id']; + unset($clean_meta['status_id']); + } if(array_key_exists('asset_eol_date', $clean_meta)) { $clean_meta['EOL date'] = $clean_meta['asset_eol_date']; unset($clean_meta['asset_eol_date']); diff --git a/resources/lang/en/admin/statuslabels/message.php b/resources/lang/en/admin/statuslabels/message.php index fe9adbf928..b1b4034d0d 100644 --- a/resources/lang/en/admin/statuslabels/message.php +++ b/resources/lang/en/admin/statuslabels/message.php @@ -3,6 +3,7 @@ return [ 'does_not_exist' => 'Status Label does not exist.', + 'deleted_label' => 'Deleted Status Label', 'assoc_assets' => 'This Status Label is currently associated with at least one Asset and cannot be deleted. Please update your assets to no longer reference this status and try again. ', 'create' => [