@props([ 'name', 'label' => null, 'checked' => false, 'value' => 1, 'onColor' => 'success', 'offColor' => 'danger', // Cambiado a danger por defecto para contraste 'onText' => 'ACTIVO', // Texto cuando está encendido 'offText' => 'INACTIVO' // Texto cuando está apagado ]) @php // Generamos un ID único para evitar conflictos si hay varios switches $id = $attributes->get('id') ?? $name . '_' . uniqid(); // Determinamos el estado inicial (para ediciones o validaciones fallidas) $isChecked = old($name, $checked); // Definimos el color y texto inicial según el estado $currentColor = $isChecked ? 'text-' . $onColor : 'text-' . $offColor; $currentText = $isChecked ? $onText : $offText; @endphp