@props([ 'name', 'options' => [], 'selected' => null, 'placeholder' => 'Search…', 'required' => false, 'emptyLabel' => 'Select…', ]) @php $optionList = collect($options)->map(function ($option) { if (is_array($option)) { return [ 'value' => (string) ($option['value'] ?? ''), 'label' => (string) ($option['label'] ?? ''), 'search' => (string) ($option['search'] ?? $option['label'] ?? ''), ]; } return [ 'value' => (string) data_get($option, 'value', data_get($option, 'id', '')), 'label' => (string) data_get($option, 'label', data_get($option, 'name', '')), 'search' => (string) data_get($option, 'search', data_get($option, 'label', data_get($option, 'name', ''))), ]; })->values()->all(); $selectedValue = old($name, $selected); $selectedValue = $selectedValue === null || $selectedValue === '' ? '' : (string) $selectedValue; @endphp