dishplanner/app/Console/Commands/PurgeDemoAccountsCommand.php

29 lines
626 B
PHP
Raw Permalink Normal View History

2026-01-08 02:09:52 +01:00
<?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;
}
}