<?php

namespace App\Providers;

use App\Models\PersonalAccessToken;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Laravel\Sanctum\Sanctum;
use Modules\Auth\Entities\User;
use Modules\Auth\Providers\AuthServiceProvider;
use App\Policies\ImpersonatePolicy;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        $this->app->register(AuthServiceProvider::class);
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);

        // Register impersonate policy
        Gate::define('impersonate', [ImpersonatePolicy::class, 'impersonate']);
        Gate::define('impersonate.user', [ImpersonatePolicy::class, 'impersonateUser']);
    }
}
