Skip to content

A free open source IT asset/license management system

Delete pending requests on hard delete

snipec5c3be204994
diff --git a/app/Console/Commands/Purge.php b/app/Console/Commands/Purge.php
index f876fb6ce7..dd36e13282 100644
--- a/app/Console/Commands/Purge.php
+++ b/app/Console/Commands/Purge.php
@@ -245,7 +245,16 @@ class Purge extends Command
// forceDeleted hook covers the direct forceDelete() path
// that bypasses this command.
Accessory::class => ['checkout_requests' => ['requestable_id', 'requestable_type', Accessory::class]],
- Consumable::class => ['checkout_requests' => ['requestable_id', 'requestable_type', Consumable::class]],
+ // consumables_users is the pivot the Consumable observer
+ // no longer detaches on soft-delete (so restores preserve
+ // the mark-consumed lifecycle). On purge we need to clean
+ // it ourselves since this path bypasses the forceDeleted
+ // Eloquent hook that handles pivot detach for in-app
+ // force-delete.
+ Consumable::class => [
+ 'consumables_users' => 'consumable_id',
+ 'checkout_requests' => ['requestable_id', 'requestable_type', Consumable::class],
+ ],
Component::class => ['checkout_requests' => ['requestable_id', 'requestable_type', Component::class]],
AssetModel::class => ['checkout_requests' => ['requestable_id', 'requestable_type', AssetModel::class]],
];