<?php

namespace Modules\Routing\Providers;

use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Support\ServiceProvider;
use Modules\Routing\Models\EvRoute;
use Modules\Routing\Models\PopularRoute;
use Modules\Routing\Models\RoutePricing;
use Modules\Routing\Observers\EvRouteObserver;
use Modules\Routing\Observers\PopularRouteObserver;
use Modules\Routing\Observers\RoutePricingObserver;
use Modules\Routing\Policies\RoutePolicy;

class RoutingServiceProvider extends ServiceProvider
{
    public function register(): void {}

    public function boot(Gate $gate): void
    {
        $gate->policy(EvRoute::class, RoutePolicy::class);
        // RoutePolicy only gates on the manage_routes permission (no
        // model-specific logic), so it's reused as-is rather than adding a
        // near-identical PopularRoutePolicy.
        $gate->policy(PopularRoute::class, RoutePolicy::class);

        EvRoute::observe(EvRouteObserver::class);
        RoutePricing::observe(RoutePricingObserver::class);
        PopularRoute::observe(PopularRouteObserver::class);
    }
}
