Created
November 29, 2024 04:59
-
-
Save dlnsk/b44aacbfbbc61a9aedd07ebc3e6f13af to your computer and use it in GitHub Desktop.
Select component (Laravel)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@props([ | |
'items', | |
'value', | |
'choose' => false, | |
]) | |
<select {{ $attributes->merge(['class' => "custom-select"]) }}> | |
@if($choose) | |
<option value="">{{ $choose }}</option> | |
@endif | |
@foreach(($items) as $k => $v) | |
<option | |
value="{{ is_int($k) ? $v : $k }}" | |
@if((is_int($k) ? $v : $k) === $value) selected @endif | |
>{{ $v }}</option> | |
@endforeach | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment