<?php

namespace App\Console\Commands;

use App\Models\EmailVerificationOtp;
use Illuminate\Console\Command;

class CleanupExpiredOtps extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'otp:cleanup';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Clean up expired and old used OTP codes';

    /**
     * Execute the console command.
     */
    public function handle(): int
    {
        $deleted = EmailVerificationOtp::cleanupExpired();

        $this->info("Cleaned up {$deleted} expired OTP records.");

        return Command::SUCCESS;
    }
}
