Skip to content

A free open source IT asset/license management system

Improve command

Marcus Moore0b065eb7fe9f
diff --git a/app/Console/Commands/RemoveInvalidUploadDeleteActionLogItems.php b/app/Console/Commands/RemoveInvalidUploadDeleteActionLogItems.php
index 599b990966..0536b6f763 100644
--- a/app/Console/Commands/RemoveInvalidUploadDeleteActionLogItems.php
+++ b/app/Console/Commands/RemoveInvalidUploadDeleteActionLogItems.php
@@ -29,13 +29,26 @@ class RemoveInvalidUploadDeleteActionLogItems extends Command
$invalidLogs = Actionlog::query()
->where('action_type', 'upload deleted')
->whereNull('filename')
+ ->withTrashed()
->get();
$this->info("{$invalidLogs->count()} invalid log items found.");
+ if ($invalidLogs->count() === 0) {
+ return 0;
+ }
- if ($invalidLogs->count() > 0 && $this->confirm("Do you wish to remove {$invalidLogs->count()} log items?")) {
- $invalidLogs->each(fn($log) => $log->delete());
+ $this->table(['ID', 'Action Type', 'Item Type', 'Item ID', 'Created At', 'Deleted At'], $invalidLogs->map(fn($log) => [
+ $log->id,
+ $log->action_type,
+ $log->item_type,
+ $log->item_id,
+ $log->created_at,
+ $log->deleted_at,
+ ])->toArray());
+
+ if ($this->confirm("Do you wish to remove {$invalidLogs->count()} log items?")) {
+ $invalidLogs->each(fn($log) => $log->forceDelete());
}
return 0;