Skip to content

Commit c675bb7

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 143a091 + e65d11d commit c675bb7

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Actionlog;
6+
use Illuminate\Console\Command;
7+
8+
class RemoveInvalidUploadDeleteActionLogItems extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'snipeit:remove-invalid-upload-delete-action-log-items';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Permanently remove invalid "upload deleted" action log items that have a null filename. This command can potentially result in deleted files being "resurrected" in the UI.';
23+
24+
/**
25+
* Execute the console command.
26+
*/
27+
public function handle()
28+
{
29+
$invalidLogs = Actionlog::query()
30+
->where('action_type', 'upload deleted')
31+
->whereNull('filename')
32+
->withTrashed()
33+
->get();
34+
35+
$this->info("{$invalidLogs->count()} invalid log items found.");
36+
37+
if ($invalidLogs->count() === 0) {
38+
return 0;
39+
}
40+
41+
$this->table(['ID', 'Action Type', 'Item Type', 'Item ID', 'Created At', 'Deleted At'], $invalidLogs->map(fn($log) => [
42+
$log->id,
43+
$log->action_type,
44+
$log->item_type,
45+
$log->item_id,
46+
$log->created_at,
47+
$log->deleted_at,
48+
])->toArray());
49+
50+
if ($this->confirm("Do you wish to remove {$invalidLogs->count()} log items?")) {
51+
$invalidLogs->each(fn($log) => $log->forceDelete());
52+
}
53+
54+
return 0;
55+
}
56+
}

resources/views/partials/bootstrap-table.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ class: 'btn-info',
608608
},
609609
attributes: {
610610
class: 'btn-info',
611-
title: '{{ trans('general.create') }}',
611+
title: '{{ trans('button.add_maintenance') }}',
612612
@if ($snipeSettings->shortcuts_enabled == 1)
613613
accesskey: 'n'
614614
@endif

0 commit comments

Comments
 (0)