feature - 23 - purge old demo accounts
This commit is contained in:
parent
f78d97dae5
commit
1de78bdce3
2 changed files with 33 additions and 0 deletions
28
app/Console/Commands/PurgeDemoAccountsCommand.php
Normal file
28
app/Console/Commands/PurgeDemoAccountsCommand.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,12 @@
|
||||||
|
|
||||||
use Illuminate\Foundation\Inspiring;
|
use Illuminate\Foundation\Inspiring;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Illuminate\Support\Facades\Schedule;
|
||||||
|
|
||||||
Artisan::command('inspire', function () {
|
Artisan::command('inspire', function () {
|
||||||
$this->comment(Inspiring::quote());
|
$this->comment(Inspiring::quote());
|
||||||
})->purpose('Display an inspiring quote')->hourly();
|
})->purpose('Display an inspiring quote')->hourly();
|
||||||
|
|
||||||
|
Schedule::command('demo:purge')
|
||||||
|
->dailyAt('03:00')
|
||||||
|
->when(fn () => is_mode_demo());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue