42 lines
988 B
PHP
42 lines
988 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Game;
|
|
|
|
use Illuminate\Console\Command;
|
|
use App\Services\Game\CooldownService;
|
|
use App\Models\Cooldown;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class ProcessCooldowns extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'game:process-cooldowns';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Process and clean up expired cooldowns';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(CooldownService $cooldownService): int
|
|
{
|
|
$this->info('Processing cooldowns...');
|
|
|
|
// Delete expired cooldowns
|
|
$maxAge = now()->subHours(24); // Keep cooldowns for 24 hours max
|
|
$deleted = Cooldown::where('last_action_at', '<', $maxAge)->delete();
|
|
|
|
$this->info("Deleted {$deleted} expired cooldown records.");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|