Agrego archivos iniciales

This commit is contained in:
Laucha1312
2026-06-04 14:47:50 -03:00
commit ed94601e34
76 changed files with 7737 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class CleanupOldEvents extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:cleanup-old-events';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Elimina eventos y QRs antiguos según la configuración del sistema.';
/**
* Execute the console command.
*/
public function handle()
{
$dias = \App\Models\Configuracion::get('dias_expiracion_eventos', 30);
$fechaLimite = now()->subDays((int)$dias);
$eventosAEliminar = \App\Models\Evento::withTrashed()
->where('fecha_evento', '<', $fechaLimite->toDateString())
->get();
$total = $eventosAEliminar->count();
if ($total === 0) {
$this->info("No hay eventos antiguos para eliminar.");
return;
}
foreach ($eventosAEliminar as $evento) {
/** @var \App\Models\Evento $evento */
// Eliminar QRs asociados
$evento->qrCodes()->delete();
// Ya no eliminamos el evento para mantener registro de puntos y goleadores
// $evento->delete();
}
$this->info("Se han limpiado los QRs de $total eventos antiguos (Antigüedad > $dias días). Los eventos permanecen en el sistema.");
}
}