<?php

namespace App\Providers;

use App\Models\Subscription;
use Illuminate\Support\ServiceProvider;
use Laravel\Cashier\Cashier;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        // Cashier registers POST stripe/webhook against its own controller. We serve
        // that URI from StripeWebhookController (routes/web.php) instead, so drop
        // Cashier's route group rather than collide on the URI. Its only other route,
        // stripe/payment/{id}, is dead here: payment notifications are not enabled.
        Cashier::ignoreRoutes();
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // Our Subscription model adds the cancel_at column that records the
        // auto-renewal choice made at checkout.
        Cashier::useSubscriptionModel(Subscription::class);
    }
}
