v0.9.2
This commit is contained in:
commit
8f8513f802
278 files changed
+18400
No files matched your search
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\Audit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use IriksIT\Manager\Models\AuditLog;
|
||||
use IriksIT\Manager\Models\AuditSetting;
|
||||
|
||||
class PruneAuditLog extends Command
|
||||
{
|
||||
protected $signature = 'manager:audit-prune';
|
||||
|
||||
protected $description = 'Delete the lines of the audit log and the ended bans that are older than the rules keep them';
|
||||
|
||||
public function handle(IpBans $bans): int
|
||||
{
|
||||
$before = now()->subDays(AuditSetting::current()->rules()['keep_days']);
|
||||
|
||||
$old = AuditLog::query()->where('created_at', '<', $before);
|
||||
$lines = $old->count();
|
||||
$old->delete();
|
||||
|
||||
$this->line(sprintf('%d line(s) of the audit log and %d ended ban(s) deleted.', $lines, $bans->forgetExpiredBefore($before)));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user