A free open source IT asset/license management system
updated column name, updated Api license checkin and out
Godfrey Mf47a2b10c0f0
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 263204853c..a980b0efac 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -1535,7 +1535,7 @@ class Helper{if (!$license->reassignable) {- $count = LicenseSeat::where('unavailable', '=', true)+ $count = LicenseSeat::where('dead', '=', true)->where('license_id', '=', $license->id)->count();return $count;diff --git a/app/Http/Controllers/Api/LicenseSeatsController.php b/app/Http/Controllers/Api/LicenseSeatsController.phpindex 2ed7097322..1017797937 100644--- a/app/Http/Controllers/Api/LicenseSeatsController.php+++ b/app/Http/Controllers/Api/LicenseSeatsController.php@@ -119,7 +119,9 @@ class LicenseSeatsController extends Controller// nothing to updatereturn response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));}-+ if( $touched && $licenseSeat->dead) {+ return response()->json(Helper::formatStandardApiResponse('error', $licenseSeat, trans('admin/licenses/message.checkout.unavailable')));+ }// the logging functions expect only one "target". if both asset and user are present in the request,// we simply let assets take precedence over users...if ($licenseSeat->isDirty('assigned_to')) {@@ -137,6 +139,10 @@ class LicenseSeatsController extends Controllerif ($is_checkin) {$licenseSeat->logCheckin($target, $request->input('note'));+ if(!$licenseSeat->license->ressignable){+ $licenseSeat->dead = 1;+ $licenseSeat->save();+ }return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));}diff --git a/app/Http/Controllers/Licenses/LicenseCheckinController.php b/app/Http/Controllers/Licenses/LicenseCheckinController.phpindex 07b063af5e..9d61b5e2f1 100644--- a/app/Http/Controllers/Licenses/LicenseCheckinController.php+++ b/app/Http/Controllers/Licenses/LicenseCheckinController.php@@ -96,7 +96,7 @@ class LicenseCheckinController extends Controller$licenseSeat->asset_id = null;$licenseSeat->notes = $request->input('notes');if (! $licenseSeat->license->reassignable) {- $licenseSeat->unavailable = 1;+ $licenseSeat->dead = 1;$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';}diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.phpindex f04c593393..55c95bb54b 100644--- a/app/Http/Transformers/LicenseSeatsTransformer.php+++ b/app/Http/Transformers/LicenseSeatsTransformer.php@@ -49,7 +49,7 @@ class LicenseSeatsTransformer'reassignable' => (bool) $seat->license->reassignable,'notes' => e($seat->notes),'user_can_checkout' => (($seat->assigned_to == '') && ($seat->asset_id == '')),- 'disabled' => $seat->unavailable,+ 'disabled' => $seat->dead,];if ($seat_count != 0) {diff --git a/database/factories/LicenseSeatFactory.php b/database/factories/LicenseSeatFactory.phpindex 2aa1c55f37..34caeb3038 100644--- a/database/factories/LicenseSeatFactory.php+++ b/database/factories/LicenseSeatFactory.php@@ -14,7 +14,7 @@ class LicenseSeatFactory extends Factory{return ['license_id' => License::factory(),- 'unavailable' => 0,+ 'dead' => 0,];}diff --git a/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.php b/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.phpindex b0ec692ea0..be123dc276 100644--- a/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.php+++ b/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.php@@ -14,7 +14,7 @@ return new class extends Migrationpublic function up(): void{Schema::table('license_seats', function (Blueprint $table) {- $table->addColumn('boolean', 'unavailable')->default(false)->after('assigned_to');+ $table->addColumn('boolean', 'dead')->default(false)->after('assigned_to');});}/**@@ -22,8 +22,8 @@ return new class extends Migration*/public function down(): void{- Schema::table('license_seats_tables', function (Blueprint $table) {- $table->dropColumn('unavailable');+ Schema::table('license_seats', function (Blueprint $table) {+ $table->dropColumn('dead');});}};diff --git a/tests/Feature/Checkins/Ui/LicenseCheckinTest.php b/tests/Feature/Checkins/Ui/LicenseCheckinTest.phpindex 093455c5e7..1a711306d1 100644--- a/tests/Feature/Checkins/Ui/LicenseCheckinTest.php+++ b/tests/Feature/Checkins/Ui/LicenseCheckinTest.php@@ -32,7 +32,7 @@ class LicenseCheckinTest extends TestCase$licenseSeat->refresh();- $this->assertEquals(1, $licenseSeat->unavailable);+ $this->assertEquals(1, $licenseSeat->dead);}public function testCannotCheckinLicenseThatIsNotAssigned()