<label for="{{ $id ?? $name }}" class="form-label">@lang($label):</label>
<select id="{{ $id ?? $name }}"
        name="{{ $name . (isset($multiple) ? '[]' : '') }}"
        class="{{ isset($selectpicker) ? 'form-control selectpicker' : 'form-select'}}  @error($name)is-invalid @enderror {{ $class ?? '' }}"
        title="@lang('Choose...')"
        {!! isset($selectpicker) && isset($liveSearch) ? ' data-live-search="true"' : '' !!}
        {!! isset($selectpicker) && isset($maxOptions) ? ' data-max-options="' . $maxOptions .'"' : '' !!}
        {{ isset($multiple) ? 'multiple' : '' }}
        {{ isset($disabled) ? ' disabled' : '' }}
        {{ isset($readonly) ? ' readonly' : '' }}
        {{ isset($disabledIf) ? ($disabledIf ? ' disabled' : '') : '' }}
        {{ isset($readonlyIf) ? ($readonlyIf ? ' readonly' : '') : '' }}>
    @foreach($options as $key => $option)
    <option value="{{ isset($keyForValue) ? $option[$keyForValue] : $key }}"
            {!! isset($selectpicker) ? ' data-tokens="' . Str::slug($option[$keyForText]) . '"' : '' !!}
            @if(isset($value))
            {{ old($name, $value) == (isset($keyForValue) ? $option[$keyForValue] : $key) ? ' selected' : ''}}
            @elseif(isset($values) && isset($multiple))
            @if(!is_array($values))
            {{ $values->contains($option[$keyForValue]) || in_array($option[$keyForValue], old($name, [])) ? ' selected' : '' }}
            @else
            {{ in_array($option[$keyForValue], old($name, $values)) ? ' selected' : '' }}
            @endif
            @endif
    >{{ isset($keyForText) ? $option[$keyForText] : $option }}</option>
    @endforeach
</select>
