<?php

namespace App\Console\Commands;

use App\Core\Services\Invoice\ReminderService;
use Illuminate\Console\Command;

class SendInvoiceReminders extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'invoices:send-reminders';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send due reminders for invoices';

    /**
     * Execute the console command.
     */
    public function handle(ReminderService $service): int
    {
        $this->info('Sending invoice reminders...');

        $count = $service->sendDueReminders();

        if ($count > 0) {
            $this->info("Successfully sent {$count} reminder(s).");
        } else {
            $this->info('No reminders to send.');
        }

        return Command::SUCCESS;
    }
}
