@props([ 'id' => null, 'name' => null, 'value' => '1', 'uncheckedValue' => null, 'checked' => false, 'indeterminate' => false, 'disabled' => false, 'label' => null, 'description' => null, 'size' => 'md', 'variant' => 'row', 'inputAttributes' => [], ]) @php $inputId = $id ?: ($name ? str_replace(['[', ']'], ['_', ''], $name) : 'ui_checkbox_'.uniqid()); $descriptionId = $description ? $inputId.'_description' : null; $inputAttributeBag = new \Illuminate\View\ComponentAttributeBag($inputAttributes); $oldValue = $name ? old($name, null) : null; if ($oldValue !== null) { $isChecked = is_array($oldValue) ? in_array((string) $value, array_map('strval', $oldValue), true) : in_array(strtolower((string) $oldValue), ['1', 'true', 'on', 'yes'], true) || (string) $oldValue === (string) $value; } else { $isChecked = filter_var($checked, FILTER_VALIDATE_BOOLEAN); } @endphp