Laravel Dynamic active menu Example Tutorial

Today, We want to share with you Laravel Dynamic active menu Example Tutorial.In this post we will show you laravel active menu item, hear for laravel request is and laravel request::is we will give you demo and example for implement.In this post, we will learn about laravel 5.7 navigation menu with an example.

Laravel Dynamic active menu Example Tutorial

There are the Following The simple About Laravel Dynamic active menu Example Tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel 5.7 active class with active states laravel, so the some major files and Directory structures for this example is following below.

Also Read This πŸ‘‰   Delay, Sleep, Pause, & Wait in JavaScript


step 1: Create a helpers.php

function isActive($path)
    return Request::is($path . '*') ? ' active' :  '';

step 2: Add in composer.json files

"autoload": {
        "classmap": [
        "files": [
        "psr-4": {
            "App\": "app/"

step 3: How to use it:

<ul class="nav navbar-nav">
    <li class="{{ isActive('products') }}">
       <a href="{{ url('products') }}"><i class="fa fa-fw fa-user"></i> Products</a>

Laravel 5.7 active menu item using request

<li class="{{ Request::is('status*') ? 'active' : '' }}">
    <a href="{!! route('status.index') !!}"><span>Status</span></a>
<li class="{{ Request::is('users*') ? 'active' : '' }}">
    <a href="{!! route('users.index') !!}"><span>Users</span></a>
<li class="{{ Request::is('roles*') ? 'active' : '' }}">
    <a href="{!! route('roles.index') !!}"><span>Roles</span></a>

Highlight Active Nav Links using Laravel

We can use ternary operator with 3 Examples. For example, We can check dynamic URI for the current ul > li route:

Also Read This πŸ‘‰   PHP Laravel 5.6 Dynamically Add Active class

using ternary operator

<li{{ request()->is('product-types') ? ' class="active"' : '' }}>

using * as wildcard:

<li{{ request()->is('product-type-number-*') ? ' class="active"' : '' }}>

using check route name

<li{{ request()->route()->getName() === 'ProductType.index' ? ' class="active"' : '' }}>

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Dynamic active menu Example Tutorial.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.