A free open source IT asset/license management system
Added created_by to license view
snipe57f6ecb1da5d
diff --git a/app/Http/Controllers/Api/LicensesController.php b/app/Http/Controllers/Api/LicensesController.phpindex 579d80eeb5..71ad01b59b 100644--- a/app/Http/Controllers/Api/LicensesController.php+++ b/app/Http/Controllers/Api/LicensesController.php@@ -24,7 +24,7 @@ class LicensesController extends Controller{$this->authorize('view', License::class);- $licenses = License::with('company', 'manufacturer', 'supplier','category')->withCount('freeSeats as free_seats_count');+ $licenses = License::with('company', 'manufacturer', 'supplier','category', 'adminuser')->withCount('freeSeats as free_seats_count');if ($request->filled('company_id')) {$licenses->where('company_id', '=', $request->input('company_id'));@@ -70,6 +70,9 @@ class LicensesController extends Controller$licenses->where('depreciation_id', '=', $request->input('depreciation_id'));}+ if ($request->filled('user_id')) {+ $licenses->where('user_id', '=', $request->input('user_id'));+ }if (($request->filled('maintained')) && ($request->input('maintained')=='true')) {$licenses->where('maintained','=',1);@@ -113,6 +116,9 @@ class LicensesController extends Controllercase 'company':$licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);break;+ case 'created_by':+ $licenses = $licenses->OrderCreatedBy($order);+ break;default:$allowed_columns =[diff --git a/app/Http/Transformers/LicensesTransformer.php b/app/Http/Transformers/LicensesTransformer.phpindex fa218da4d1..4fad9b9a68 100644--- a/app/Http/Transformers/LicensesTransformer.php+++ b/app/Http/Transformers/LicensesTransformer.php@@ -45,6 +45,10 @@ class LicensesTransformer'maintained' => ($license->maintained == 1) ? true : false,'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id, 'name'=> e($license->supplier->name)] : null,'category' => ($license->category) ? ['id' => (int) $license->category->id, 'name'=> e($license->category->name)] : null,+ 'created_by' => ($license->adminuser) ? [+ 'id' => (int) $license->adminuser->id,+ 'name'=> e($license->adminuser->present()->fullName()),+ ] : null,'created_at' => Helper::getFormattedDateObject($license->created_at, 'datetime'),'updated_at' => Helper::getFormattedDateObject($license->updated_at, 'datetime'),'deleted_at' => Helper::getFormattedDateObject($license->deleted_at, 'datetime'),diff --git a/app/Models/License.php b/app/Models/License.phpindex 2680424a84..554929c0ac 100755--- a/app/Models/License.php+++ b/app/Models/License.php@@ -736,4 +736,17 @@ class License extends Depreciablereturn $query->leftJoin('companies as companies', 'licenses.company_id', '=', 'companies.id')->select('licenses.*')->orderBy('companies.name', $order);}++ /**+ * Query builder scope to order on the user that created it+ *+ * @param \Illuminate\Database\Query\Builder $query Query builder instance+ * @param text $order Order+ *+ * @return \Illuminate\Database\Query\Builder Modified query builder+ */+ public function scopeOrderCreatedBy($query, $order)+ {+ return $query->leftJoin('users as users_sort', 'licenses.user_id', '=', 'users_sort.id')->select('licenses.*')->orderBy('users_sort.first_name', $order)->orderBy('users_sort.last_name', $order);+ }}\ No newline at end of filediff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.phpindex 8ca8e120f2..1545cabd30 100644--- a/app/Presenters/LicensePresenter.php+++ b/app/Presenters/LicensePresenter.php@@ -158,6 +158,13 @@ class LicensePresenter extends Presenter'sortable' => true,'visible' => false,'title' => trans('general.order_number'),+ ], [+ 'field' => 'created_by',+ 'searchable' => false,+ 'sortable' => true,+ 'title' => trans('general.admin'),+ 'visible' => false,+ 'formatter' => 'usersLinkObjFormatter',], ['field' => 'created_at','searchable' => false,