<?php

namespace Modules\Auth\Policies;

use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Modules\Auth\Models\Role;
use Modules\Core\Enums\RolesEnum;

class RolePolicy
{
    use HandlesAuthorization;

    public function viewAny(User $authUser): bool
    {
        return $authUser->can('auth.roles.view');
    }

    public function updateRolePermissions(User $authUser, Role $role): bool
    {
        return $authUser->can('auth.roles.assign')
            && $role->name !== RolesEnum::SUPER_ADMIN->value;
    }
}
