Files
sam-api/app/Console/Commands/PruneAuditLogs.php
hskwon cc206fdbed style: Laravel Pint 코드 포맷팅 적용
- PSR-12 스타일 가이드 준수
- 302개 파일 스타일 이슈 자동 수정
- 코드 로직 변경 없음 (포맷팅만)
2025-11-06 17:45:49 +09:00

26 lines
717 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\Audit\AuditLog;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
class PruneAuditLogs extends Command
{
protected $signature = 'audit:prune {--days=}';
protected $description = 'Delete audit logs older than given days (default: config(audit.retention_days)).';
public function handle(): int
{
$days = (int) ($this->option('days') ?? config('audit.retention_days', 395));
$cutoff = Carbon::now()->subDays($days);
$count = AuditLog::query()->where('created_at', '<', $cutoff)->delete();
$this->info("Pruned {$count} audit log rows older than {$days} days.");
return self::SUCCESS;
}
}