<?php

namespace App\Providers;

//use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use App\Models\User;
use App\Models\Document;
use App\Models\Project;
use App\Models\Folder;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use App\Policies\UserPolicy;
use App\Policies\DocumentPolicy;
use App\Policies\ProjectPolicy;
use App\Policies\FolderPolicy;
use App\Policies\RolePolicy;
use App\Policies\PermissionPolicy;

class AuthServiceProvider extends ServiceProvider
{

    /**
     * The policy mappings for the application.
     *
     * @var array<class-string, class-string>
     */
    protected $policies = [
        User::class => UserPolicy::class,
        
        Project::class => ProjectPolicy::class,
        Folder::class => FolderPolicy::class,
        Document::class => DocumentPolicy::class,

        Role::class => RolePolicy::class,
        Permission::class => PermissionPolicy::class,
    ];



    /**
     * Register services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        $this->registerPolicies();

        // Configuración adicional de gates aquí si es necesario
        Gate::before(function ($user, $ability) {
            return $user->hasRole('admin') ? true : null;
        });
    }
}
