feature - 23 - purge old demo accounts

This commit is contained in:
myrmidex 2026-01-08 02:09:52 +01:00
parent f78d97dae5
commit 1de78bdce3
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,28 @@
<?php
namespace App\Console\Commands;
use App\Models\Planner;
use Illuminate\Console\Command;
class PurgeDemoAccountsCommand extends Command
{
protected $signature = 'demo:purge';
protected $description = 'Purge demo accounts older than 24 hours';
public function handle(): int
{
if (! is_mode_demo()) {
$this->error('This command can only run in demo mode.');
return self::FAILURE;
}
$count = Planner::where('created_at', '<', now()->subHours(24))->delete();
$this->info("Purged {$count} demo accounts.");
return self::SUCCESS;
}
}

View file

@ -2,7 +2,12 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote')->hourly();
Schedule::command('demo:purge')
->dailyAt('03:00')
->when(fn () => is_mode_demo());