Skip to content

Instantly share code, notes, and snippets.

@dlnsk
Created November 29, 2024 04:59
Show Gist options
  • Save dlnsk/b44aacbfbbc61a9aedd07ebc3e6f13af to your computer and use it in GitHub Desktop.
Save dlnsk/b44aacbfbbc61a9aedd07ebc3e6f13af to your computer and use it in GitHub Desktop.
Select component (Laravel)
@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