This commit is contained in:
2025-09-18 15:31:27 +02:00
commit 2abba0c2b7
406 changed files with 31879 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use App\Models\PopularDaily;
use App\Models\PopularWeekly;
use App\Models\PopularMonthly;
use Illuminate\Support\Carbon;
use Illuminate\Console\Command;
class AutoStats extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:auto-stats';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear Outdated Popular Stats';
/**
* Execute the console command.
*/
public function handle()
{
PopularDaily::where('created_at', '<=', Carbon::now()->subMinutes(1440))->forceDelete();
PopularWeekly::where('created_at', '<=', Carbon::now()->subMinutes(10080))->forceDelete();
PopularMonthly::where('created_at', '<=', Carbon::now()->subMinutes(43200))->forceDelete();
$this->comment('Automated Purge Stats Complete');
}
}