Reputation: 111
I am new in Laravel, I'm trying to give active class to menu links if current url matches the menu link url,
<li @if (Request::is('student/lecture') || Request::is('admin/lecture/*')) class="active" @endif >
<a href="{{ url('student/lecture') }}"><i class="fa fa-globe"></i>Lectures </a>
</li>
Its working for student/lecture
or student/lecture/*
, but its not wokring for student/lecture/13?id=30
( without sending id in get it work, but its not working when id is passed).
Upvotes: 3
Views: 6298
Reputation: 1
Simply use this one:
Request::is('user-wallet*')
Instead of this one:
Request::is('user-wallet/*')
The slash before the astrix will make the difference.
Upvotes: 0
Reputation: 8350
Try the following:
<li{!! (Request::is('student/lecture') || Request::is('admin/lecture/*') ? ' class="active"' : '') !!}>
<a href="{{ url('student/lecture') }}"><i class="fa fa-globe"></i>Lectures </a>
</li>
Upvotes: 0