diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php index 6eedfcf5ed..7f76d3baac 100644 --- a/app/Http/Transformers/ActionlogsTransformer.php +++ b/app/Http/Transformers/ActionlogsTransformer.php @@ -156,10 +156,9 @@ class ActionlogsTransformer * @param array $clean_meta * @return array */ - public function changedInfo(array $clean_meta) { - $location = Location::withTrashed()->get(); - $company = Company::withTrashed()->get(); + public function changedInfo(array $clean_meta) + { $location = Location::withTrashed()->get(); $supplier = Supplier::withTrashed()->get(); $model = AssetModel::withTrashed()->get(); @@ -180,12 +179,19 @@ class ActionlogsTransformer $clean_meta['model_id']['old'] = "[id: ".$clean_meta['model_id']['old']."] ".$model->find($clean_meta['model_id']['old'])->name; $clean_meta['model_id']['new'] = "[id: ".$clean_meta['model_id']['new']."] ".$model->find($clean_meta['model_id']['new'])->name; /* model is required at asset creation */ + $clean_meta['Model'] = $clean_meta['model_id']; unset($clean_meta['model_id']); } if(array_key_exists('company_id', $clean_meta)) { - $clean_meta['company_id']['old'] = $clean_meta['company_id']['old'] ? "[id: ".$clean_meta['company_id']['old']."]".$company->find($clean_meta['company_id']['old'])->name : trans('general.unassigned'); - $clean_meta['company_id']['new'] = $clean_meta['company_id']['new'] ? "[id: ".$clean_meta['company_id']['new']."] ".$company->find($clean_meta['company_id']['new'])->name : trans('general.unassigned'); + $oldCompany = Company::find($clean_meta['company_id']['old']); + $oldCompanyName = $oldCompany->name ?? trans('admin/companies/message.deleted'); + + $newCompany = Company::find($clean_meta['company_id']['new']); + $newCompanyName = $newCompany->name ?? trans('admin/companies/message.deleted'); + + $clean_meta['company_id']['old'] = $clean_meta['company_id']['old'] ? "[id: ".$clean_meta['company_id']['old']."] ". $oldCompanyName : trans('general.unassigned'); + $clean_meta['company_id']['new'] = $clean_meta['company_id']['new'] ? "[id: ".$clean_meta['company_id']['new']."] ". $newCompanyName : trans('general.unassigned'); $clean_meta['Company'] = $clean_meta['company_id']; unset($clean_meta['company_id']); } diff --git a/resources/lang/en/admin/companies/message.php b/resources/lang/en/admin/companies/message.php index b44bdd4b85..e440b7ac5f 100644 --- a/resources/lang/en/admin/companies/message.php +++ b/resources/lang/en/admin/companies/message.php @@ -2,6 +2,7 @@ return [ 'does_not_exist' => 'Company does not exist.', + 'deleted' => 'Deleted company', 'assoc_users' => 'This company is currently associated with at least one model and cannot be deleted. Please update your models to no longer reference this company and try again. ', 'create' => [ 'error' => 'Company was not created, please try again.',