PHP Laravel 5.6 Dynamically Add Active class

Today, We want to share with you PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu.In this post we will show you php – Setting Bootstrap navbar active class in Laravel 5.6, hear for Add active class to old dynamic nav using 5.6 and bootstrap 4 we will give you demo and example for implement.In this post, we will learn about Adding class .active to current link in Laravel 5.6 with an example.

PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu

There are the Following The simple About PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu Full Information With Example and source code.

Also Read :  PHP Sorting Arrays Tutorial With Examples

As I will cover this Post with live Working example to develop How add active state to the navigation menu with Laravel 5.6, so the some major files and Directory structures for this example is following below.

  • Laravel 5.6 active menu
  • Laravel 5 active menu

Laravel 5.6 active menu item using request

check route name

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

use * as wildcard

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

use ternary operator

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

Laravel 5.5 active menu item using request

<li class="{{ Request::is('products*') ? 'active' : '' }}">
    <a href="{!! route('products.index') !!}"><span>Products</span></a>
</li>

<li class="{{ Request::is('category*') ? 'active' : '' }}">
    <a href="{!! route('category.index') !!}"><span>Category</span></a>
</li>

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

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read :  Fresher PHP WEB Developer Salary Range Level

Summary

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

I hope you get an idea about PHP Laravel 5.6 Dynamically Add Active class to The Navigation Menu.
I would like to have feedback on my Pakainfo.com 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.

Recommended For You.

Handling Active Navigation Menu in Laravel Example
Today, We want to share with you Handling Active Navigation Menu in Laravel Example.In this post we will show you

Add a Comment

Your email address will not be published. Required fields are marked *