@props([ 'label' => '', 'name', 'items' => collect(), /* Atributo/clave a usar como value y como texto */ 'value' => 'id', 'text' => 'name', 'selected' => null, 'placeholder' => 'Seleccione una opción', 'variant' => 'primary', ]) @php $valueSelected = old($name, $selected); $options = $items ->mapWithKeys( fn($item) => [ data_get($item, $value) => data_get($item, $text), ], ) ->all(); if (!array_key_exists('', $options)) { $options = ['' => $placeholder] + $options; } @endphp @php // Paleta por variante $palette = [ 'primary' => 'select-primary', 'secondary' => 'select-secondary', ][$variant] ?? ''; @endphp