Club System
This commit is contained in:
26
app/Console/Commands/DeleteRejectedEntries.php
Normal file
26
app/Console/Commands/DeleteRejectedEntries.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user