I should load the subcategories to the parent category, in this example I suspect a relation called children
$catecories = Category::whereNull('parent_id')->with('children')->get();
And in your blade
@foreach ($categories as $category)
//html before the subcategories
@foreach($category->children as $subcategory)
// the html for the subcategory
@endforeach
//html after the subcategories
@endforeach
Edit:
No I read your post again this is maybe not directly an answer to your question. My html/css skills aren't good so I can't help you with that. But because I think the example I give is a improvement of the code I don't remove it.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community