Skip to content

Instantly share code, notes, and snippets.

@rakeshsoni18
Last active July 28, 2019 17:51
Show Gist options
  • Select an option

  • Save rakeshsoni18/bb143b31493beb1a49991874f6683259 to your computer and use it in GitHub Desktop.

Select an option

Save rakeshsoni18/bb143b31493beb1a49991874f6683259 to your computer and use it in GitHub Desktop.
Multi Level Category in Select Option
// Two Level
@foreach($categories as $category)
<option value="{{$category->id}}">{{$category->name}}</option>
@foreach($category->subcategory as $sub)
<option value="{{$sub->id}}">-{{$sub->name}}</option>
@endforeach
@endforeach
// Three Level
@foreach($categories as $category)
<option value="{{$category->id}}">{{$category->name}}</option>
@foreach($category->subcategory as $sub)
<option value="{{$sub->id}}">-{{$sub->name}}</option>
@foreach($sub->subcategory as $subsub)
<option value="{{$subsub->id}}">--{{$subsub->name}}</option>
@endforeach
@endforeach
@endforeach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment