<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;

class AuthServiceProvider extends ServiceProvider
{
    protected $policies = [];

    public function boot(): void
    {
        $this->registerPolicies();

        Gate::before(function ($user, string $ability) {
            $role = strtolower((string)($user->role ?? ''));
            if ($role === 'admin' || $role === 'super_admin') {
                return true;
            }
            return null;
        });
    }
}

