<?php

use App\Domains\Purchase\Services\CheckoutService;
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;

Artisan::command('inspire', function () {
    $this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');

Artisan::command('purchases:expire', function (): void {
    $expiredCount = app(CheckoutService::class)
        ->expireOverduePurchases();

    $this->info("Expired purchases: {$expiredCount}");
})->purpose('Release stock reservations from expired purchases');

Schedule::command('purchases:expire')
    ->everyMinute()
    ->withoutOverlapping();
