Created
January 27, 2024 01:39
-
-
Save davidbirkin/809164dece76699b49ce843087494b1b to your computer and use it in GitHub Desktop.
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
<!-- 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