Answers for "laravel add active class to menu"

PHP
4

laravel active menu item

// check using uri
<li class="{{ request()->is('sites/*/edit') ? 'active' : '' }}"
 // or, check using route name
<li class="{{ request()->routeIs('sites/*/edit') ? 'active' : '' }}"
  // or, using segment
<li class="{{ (request()->segment(2) == 'cities') ? 'active' : '' }}">
Posted by: Guest on May-01-2021
1

laravel sidebar menu active

{{  request()->routeIs('news.*') ? 'active' : '' }}
Posted by: Guest on August-16-2020
0

laravel assign active based on route name

<li class = "{{ set_active('admin/users') }}">
    <a href="{{ url('/admin/users/') }}">Users</a>
</li>
Posted by: Guest on December-23-2020
0

laravel assign active based on route name

function set_active( $route ) {
    if( is_array( $route ) ){
        return in_array(Request::path(), $route) ? 'active' : '';
    }
    return Request::path() == $route ? 'active' : '';
}
Posted by: Guest on December-23-2020
0

nav active in laravel

//  check using route name
<li class="{{ request()->routeIs('city/create') ? 'active' : '' }}"
Posted by: Guest on October-02-2021

Browse Popular Code Answers by Language