46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use App\Services\NeblogisticAuditService;
|
|
|
|
class CleanupNeblogisticAuditLogs extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'neblogistic:cleanup-audit-logs {--months=6 : Number of months to keep}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Clean up neblogistic audit trail logs older than specified months (default: 6 months)';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$months = (int) $this->option('months');
|
|
|
|
$this->info("Cleaning up neblogistic audit trail logs older than {$months} months...");
|
|
|
|
$deleted = NeblogisticAuditService::cleanupOldLogs($months);
|
|
|
|
if ($deleted > 0) {
|
|
$this->info("Successfully deleted {$deleted} audit trail log entries.");
|
|
} else {
|
|
$this->info("No audit trail logs found to delete.");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|