<?php

namespace App\Console\Commands;

use App\Services\SubscriptionService;
use Illuminate\Console\Command;

class CheckExpiredSubscriptions extends Command
{
    protected $signature = 'subscriptions:check-expired';

    protected $description = 'Check for and expire overdue subscriptions';

    public function handle(SubscriptionService $service): int
    {
        $this->info('Checking for expired subscriptions...');

        $count = $service->checkExpiredSubscriptions();

        if ($count > 0) {
            $this->info("Expired {$count} subscription(s).");
        } else {
            $this->info('No expired subscriptions found.');
        }

        return self::SUCCESS;
    }
}
