From b054017c9f422d37c32b137b49ce04dc2a4e9533 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 11 Oct 2024 11:16:24 +0100 Subject: [PATCH] Fixed #15651 - admin user now displaying on maintenances page Signed-off-by: snipe --- app/Http/Transformers/AssetMaintenancesTransformer.php | 2 +- app/Models/AssetMaintenance.php | 2 +- app/Presenters/AssetMaintenancesPresenter.php | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/Http/Transformers/AssetMaintenancesTransformer.php b/app/Http/Transformers/AssetMaintenancesTransformer.php index c5f0abbaab..81b4a9eabb 100644 --- a/app/Http/Transformers/AssetMaintenancesTransformer.php +++ b/app/Http/Transformers/AssetMaintenancesTransformer.php @@ -66,7 +66,7 @@ class AssetMaintenancesTransformer 'completion_date' => Helper::getFormattedDateObject($assetmaintenance->completion_date, 'date'), 'user_id' => ($assetmaintenance->adminuser) ? [ 'id' => $assetmaintenance->adminuser->id, - 'name'=> e($assetmaintenance->admin->getFullNameAttribute()) + 'name'=> e($assetmaintenance->adminuser->present()->fullName()) ] : null, // legacy to not change the shape of the API 'created_by' => ($assetmaintenance->adminuser) ? [ 'id' => (int) $assetmaintenance->adminuser->id, diff --git a/app/Models/AssetMaintenance.php b/app/Models/AssetMaintenance.php index f629b03dfb..246220f5c7 100644 --- a/app/Models/AssetMaintenance.php +++ b/app/Models/AssetMaintenance.php @@ -176,7 +176,7 @@ class AssetMaintenance extends Model implements ICompanyableChild */ public function adminuser() { - return $this->belongsTo(\App\Models\User::class, 'user_id') + return $this->belongsTo(\App\Models\User::class, 'created_by') ->withTrashed(); } diff --git a/app/Presenters/AssetMaintenancesPresenter.php b/app/Presenters/AssetMaintenancesPresenter.php index 6a315ad8e0..ca49c931a4 100644 --- a/app/Presenters/AssetMaintenancesPresenter.php +++ b/app/Presenters/AssetMaintenancesPresenter.php @@ -116,12 +116,6 @@ class AssetMaintenancesPresenter extends Presenter 'sortable' => true, 'title' => trans('admin/asset_maintenances/form.cost'), 'class' => 'text-right', - ], [ - 'field' => 'user_id', - 'searchable' => true, - 'sortable' => true, - 'title' => trans('general.admin'), - 'formatter' => 'usersLinkObjFormatter', ], [ 'field' => 'created_by', 'searchable' => false,