
@php

    $inputAttributes = $attributes->merge([
        'class' => "form-select select2 $class",
        'name' => $name,
        'id' => $id,
        'data-control' => "select2",
        'data-allow-clear' => "true",
        'data-dropdown-parent' => $parent,
        'data-placeholder' => !empty($placeholder) ? $placeholder : __("Please select"),

        'disabled' => $disabled,
        'required' => $required,
    ]);

@endphp


<select {{ $inputAttributes }} >
    <option></option>
    @if(!empty($options))
        @foreach ($options as $key => $value)
            @if(is_array($value))
                <option value="{{ $key }}" {{ (string) $selected === (string) $key ? 'selected' : '' }}>
                    {{ $value[$valueName] ?? '' }}
                </option>
            @else
                <option value="{{ $key }}" {{ (string) $selected === (string) $key ? 'selected' : '' }}>
                    {{ __($value, [], !empty($clocale) ? $clocale : app()->getLocale() ) }}
                </option>
            @endif
        @endforeach
    @endif
</select>
<span data-name="{{ $name }}"></span>
