Answer the question
In order to leave comments, you need to log in
Why is it not output via @foreach laravel?
There is a header.blade.php file that includes the top_menu.balde.php file, which is responsible for the menu.
if you just write something in top_menu.balde.php, then it is displayed in the place where the menu should be, and if you write something inside "@foreach" then it is not displayed, what could be the problem?
@foreach ($categories as $category)
@if ($category->children->where('published', 1 )->count())
<li class="dropdown">
<a href="{{url("/blog/category/$category->slug")}}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{$category->title}} <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
@include('layouts.top_menu', ['categories'=>$category->children])
</ul>
@else
<li>
<a href="{{url("/blog/category/$category->slug")}}">{{$category->title}}</a>
@endif
</li>
@endforeach
<ul class="nav navbar-nav">
@include('layouts.top_menu', ['categories' => $categories])
</ul>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question