Skip to content

Commit

Permalink
Merge pull request #8 from Godmartinz/fix-companyable
Browse files Browse the repository at this point in the history
Fix companyable
  • Loading branch information
Godmartinz authored Aug 29, 2023
2 parents 92e88a0 + d86c63c commit 0ac5d4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/Http/Transformers/ActionlogsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ public function transformCheckedoutActionlog (Collection $accessories_users, $to
* @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();

Expand All @@ -180,12 +179,19 @@ public function changedInfo(array $clean_meta) {

$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']);
}
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/admin/companies/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down

0 comments on commit 0ac5d4d

Please sign in to comment.