I'm trying to set active class in my list item, but it doesn't work.
My code in blade:
@foreach($data as $site)
<ul class="sidebar-menu" id="second-menu">
@if(isAdmin())<li class="{{-- active class for url parameter --}}"><a href="{{ url('sites/'.$site->id.'/edit') }}" >{{ $site->name }}</a></li>
@endif
</ul>
@endforeach
So, if I write: li class="@if(getRouteName() == 'site@index'){{ 'active' }}@endif" , it works nice, but in my case the problem is that I want to get 'active' class in foreach sites/'.$site->id.'/edit
Many thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…