<?php

namespace App\Providers;

use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        if (App::environment('production')) {
            URL::forceScheme('https');
        }
        // if (app()->environment('local', 'testing', 'Staging')) {
        //     URL::forceScheme('http');
        // }
        Gate::before(function ($user, $ability) {
            if ($user->email == env("SUPER_ADMIN_ACCOUNT", "admin@ogilvy.com")) {
                return true; // Super admin always passes
            }
            // Continue to policy logic for other users
            return null; // Null lets the policy decide
        });
    }
}
