Hi I need to do multiple category entries. In the drop-down menu.
I have a table with 4 columns [id, title, url, parent_id]. Of which ID, and title I list in the drop-down menu. But I would need them to be listed as they are recursively stored in the database
Which I partially succeed in using the following code:
<div class="form-group">
<label>Kategorie</label>
<select class="form-control" name="parent_id">
<option selected disabled>Vyberte ID rodičovské položky</option>
@foreach($allMenus as $menu)
<option value="{{ $menu->id }}">{{$menu->title}}</option>
@foreach($menu->childs as $sub)
<option value="{{ $sub->id }}">-{{ $sub->title }}</option>
@endforeach
@endforeach
</select>
</div>
However, this sinks exactly as it is stored in the database. This causes some items to be displayed twice, e.g
The category of traction battery belongs to the category of source. The source category belongs to the electronics category.
And when I list, I see this
-Electronics
--traction battery
--powersource
--pencil batteries
-traction battery
--use of traction battery
--disposal of traction battery
But I need such a view
-Electronics
--traction battery¨
---use of traction battery
---disposal of traction battery
--powersource
--pencil batteries
How can I do the immersion so that it is not unnecessarily confused