29 lines
626 B
PHP
29 lines
626 B
PHP
|
|
<?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;
|
||
|
|
}
|
||
|
|
}
|