Skip to content

Instantly share code, notes, and snippets.

@davidbirkin
Created January 27, 2024 01:39
Show Gist options
  • Save davidbirkin/809164dece76699b49ce843087494b1b to your computer and use it in GitHub Desktop.
Save davidbirkin/809164dece76699b49ce843087494b1b to your computer and use it in GitHub Desktop.
<!-- Route -->
Route::get('/test', function () {
$options = [
'' => 'Select',
'active' => 'Active',
'ended' => 'End'
];
return view('test')->with([
'options' => $options
]);
});
<!-- Component -->
@props(['array','name','id'])
<div>
<select id="{{ $name }}"
name="{{ $id }}" {!! $attributes->merge(['class' => 'rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:max-w-xs sm:text-sm sm:leading-6']) !!}>
@foreach ($array as $value => $text)
<option value="{{ $value }}">{{ $text }}</option>
@endforeach
</select>
</div>
<!-- Calling Component -->
<x-select-test :array="$options" name="Some Name" id="Some Name"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment