27 lines
692 B
PHP
27 lines
692 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Entry;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
|
|
#[Signature('entries:purge-rejected {--days=7}')]
|
|
#[Description('Soft Delete rejected entries older than X days')]
|
|
class DeleteRejectedEntries extends Command
|
|
{
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$days = (int) $this->option('days');
|
|
$count = Entry::where('state', 'rejected')
|
|
->where('rejected_at', '<', now()->subDays($days))
|
|
->delete();
|
|
|
|
$this->info("Deleted {$count} entries");
|
|
}
|
|
}
|