From 3bc346848ce01d33bc13344b35e474340f2a859b Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 2 Jan 2021 15:12:58 -0800 Subject: [PATCH] Add support for optgroups in select lists --- app/View/Components/Inputs/Select.php | 6 +++--- .../components/inputs/select-options.blade.php | 13 +++++++++++++ resources/views/components/inputs/select.blade.php | 7 +------ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 resources/views/components/inputs/select-options.blade.php diff --git a/app/View/Components/Inputs/Select.php b/app/View/Components/Inputs/Select.php index d0aa996..0f26a23 100644 --- a/app/View/Components/Inputs/Select.php +++ b/app/View/Components/Inputs/Select.php @@ -8,17 +8,17 @@ use Illuminate\View\Component; class Select extends Component { - public Collection $options; + public Collection|array $options; public ?string $selectedValue; /** * Select constructor. * - * @param \Illuminate\Support\Collection $options + * @param \Illuminate\Support\Collection|array $options * @param ?string $selectedValue */ public function __construct( - Collection $options, + Collection|array $options, ?string $selectedValue = '', ) { $this->options = $options; diff --git a/resources/views/components/inputs/select-options.blade.php b/resources/views/components/inputs/select-options.blade.php new file mode 100644 index 0000000..5759f68 --- /dev/null +++ b/resources/views/components/inputs/select-options.blade.php @@ -0,0 +1,13 @@ +@foreach ($options as $option) + @if(is_iterable($option['value'])) + + + + @else + + @endif +@endforeach diff --git a/resources/views/components/inputs/select.blade.php b/resources/views/components/inputs/select.blade.php index e4f481e..5b9e250 100644 --- a/resources/views/components/inputs/select.blade.php +++ b/resources/views/components/inputs/select.blade.php @@ -1,9 +1,4 @@