A free open source IT asset/license management system
Fixed 1001 query on license
snipe634a4afa7581
diff --git a/app/Http/Controllers/Api/LicensesController.php b/app/Http/Controllers/Api/LicensesController.phpindex 581a23a360..de43926b7d 100644--- a/app/Http/Controllers/Api/LicensesController.php+++ b/app/Http/Controllers/Api/LicensesController.php@@ -182,7 +182,7 @@ class LicensesController extends Controllerpublic function show($id) : JsonResponse | array{$this->authorize('view', License::class);- $license = License::withCount('freeSeats')->findOrFail($id);+ $license = License::withCount('freeSeats as free_seats_count')->findOrFail($id);$license = $license->load('assignedusers', 'licenseSeats.user', 'licenseSeats.asset');return (new LicensesTransformer)->transformLicense($license);diff --git a/app/Http/Transformers/LicensesTransformer.php b/app/Http/Transformers/LicensesTransformer.phpindex b30b603016..06eb172906 100644--- a/app/Http/Transformers/LicensesTransformer.php+++ b/app/Http/Transformers/LicensesTransformer.php@@ -61,7 +61,7 @@ class LicensesTransformer'checkin' => Gate::allows('checkin', License::class),'clone' => Gate::allows('create', License::class),'update' => Gate::allows('update', License::class),- 'delete' => (Gate::allows('delete', License::class) && ($license->seats == $license->availCount()->count())) ? true : false,+ 'delete' => (Gate::allows('delete', License::class) && ($license->free_seat_count > 0)) ? true : false,];$array += $permissions_array;