Merge pull request #8 from Godmartinz/fix-companyable

Fix companyable
This commit is contained in:
Godfrey Martinez 2023-08-28 19:38:27 -07:00 committed by GitHub
commit 0ac5d4d582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -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']);
}

View file

@ -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.',