12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
37
app/Console/Commands/PurgeMagicLinks.php
Normal file
37
app/Console/Commands/PurgeMagicLinks.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\MagicLink;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Löscht verbrauchte oder abgelaufene Magic-Links, die älter als 30 Tage sind.
|
||||
* Läuft täglich via Scheduler.
|
||||
*/
|
||||
class PurgeMagicLinks extends Command
|
||||
{
|
||||
protected $signature = 'magic-links:purge {--days=30 : Links älter als X Tage löschen}';
|
||||
|
||||
protected $description = 'Löscht verbrauchte und abgelaufene Magic-Links.';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$days = (int) $this->option('days');
|
||||
$cutoff = now()->subDays($days);
|
||||
|
||||
$deleted = MagicLink::query()
|
||||
->where(function ($q) use ($cutoff): void {
|
||||
$q->where('expires_at', '<', $cutoff)
|
||||
->orWhere(function ($q) use ($cutoff): void {
|
||||
$q->whereNotNull('consumed_at')
|
||||
->where('consumed_at', '<', $cutoff);
|
||||
});
|
||||
})
|
||||
->delete();
|
||||
|
||||
$this->info("Magic-Links bereinigt: {$deleted} Einträge gelöscht.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue