A free open source IT asset/license management system
Adjusted missing down on migration and code smells
arne-kroegere8d014707591
diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.phpindex 12f3f0e54e..b1506e4f40 100644--- a/app/Http/Controllers/Api/AccessoriesController.php+++ b/app/Http/Controllers/Api/AccessoriesController.php@@ -314,7 +314,7 @@ class AccessoriesController extends Controller*/public function checkin(Request $request, $accessoryUserId = null){- if (is_null($accessory_checkout = DB::table('accessories_checkout')->find($accessoryUserId))) {+ if (is_null($accessory_checkout = AccessoryCheckout::find($accessoryUserId))) {return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist')));}@@ -324,7 +324,7 @@ class AccessoriesController extends Controller$logaction = $accessory->logCheckin(User::find($accessory_checkout->assigned_to), $request->input('note'));// Was the accessory updated?- if (DB::table('accessories_checkout')->where('id', '=', $accessory_checkout->id)->delete()) {+ if ($accessory_checkout->delete()) {if (! is_null($accessory_checkout->assigned_to)) {$user = User::find($accessory_checkout->assigned_to);}diff --git a/database/migrations/2024_07_26_143301_add_checkout_for_all_types_to_accessories.php b/database/migrations/2024_07_26_143301_add_checkout_for_all_types_to_accessories.phpindex 41c4e506fc..bde3bc2c28 100644--- a/database/migrations/2024_07_26_143301_add_checkout_for_all_types_to_accessories.php+++ b/database/migrations/2024_07_26_143301_add_checkout_for_all_types_to_accessories.php@@ -33,6 +33,10 @@ return new class extends Migrationpublic function down(): void{if (Schema::hasTable('accessories_checkout')) {+ Schema::table('accessories_checkout', function (Blueprint $table) {+ $table->dropColumn('assigned_type');+ });+Schema::rename('accessories_checkout', 'accessories_users');}}