How to indent option in select or put hyphens befo

2019-08-26 22:01发布

问题:

I want to one indent of put hyphens before each sub categories option in select box. Basically i have generated select box using blade recursion and the select box generation properly, But the issue with the option is sub category option not indenting or i am not able to put indent/hyphens before options.

Blade page

@if (count($configList) > 0)
    <select name="category">
       <option value="0">Select a Category</option>
        @include('admin.configuration.selectoption', $configList)
     </select>
@endif

Recursive blade page to generate options

Recursive blade page

 @foreach($configList as $item)
    @if(isset($category))
        @if($category[0]->parentid == $item->id)
            <option value="{{ $item->id }}" selected>
                {{ $item->configname }}
            </option>
        @else
            <option value="{{ $item->id }}">
                {{ $item->configname }}
            </option>
        @endif
    @else
        <option value="{{ $item->id }}">
            {{ $item->configname }}
        </option>
    @endif
    @if(!empty($item->children)) {{-- Or however you want to check for children --}}
        @if(isset($category))
            @include('admin.configuration.selectoption', ['configList' => $item['children'], 'category' => $category]){{-- Here I am just telling blade to treat the children as $items where they are passed through --}}
        @else
            @include('admin.configuration.selectoption', ['configList' => $item['children']]){{-- Here I am just telling blade to treat the children as $items where they are passed through --}}   
        @endif
    @endif
@endforeach

Above Code working perfectly but the option not indented. I want to generate the indent or space or hyphens before option based on level on recursion.