PHP Laravel Set Active Menu Examples

Today, We want to share with you PHP Laravel Set Active Menu Examples.In this post we will show you active menu in laravel 5.7, hear for Laravel 5.7 Set Active Navigation State we will give you demo and example for implement.In this post, we will learn about add active navigation class based on url in laravel with an example.

PHP Laravel Set Active Menu Examples

There are the Following The simple About PHP Laravel Set Active Menu Examples Full Information With Example and source code.

As I will cover this Post with live Working example to develop router link active laravel, so the some laravel 5.7 active menu item for this example is following below.

Also Read This 👉   Laravel Send Email Attachment Tutorial With Example

Example 1: helper function:

Sets Laravel Dynamic active class on navigation

    /*
      Sets active class on navigation.
    */
    public static function setActive($path, $active = 'active') {
      return  Request::is($path) ? $active : '';
    }

nav template

<li class="{{ Helper::setActive('products') }}"><a href="/products">Products/a></li>

in Advance Set Active Navigation full State

the nav menu to still be active for “Products” when we are viewing a products create (ie – /products/create), product Listing (ie – /products/list).

    /*
      Sets active class on navigation.
    */
    public static function setActive($path, $active = 'active') {
      return  Str::contains(Request::path(), $path) ? $active : '';
    }

Example 2: Bootstrap navbar active class in Laravel 5.7

Laravel Dynamic Menu Active Example

<ul class="nav nav-pills pull-right">
    <li class="{{ Request::is('/') ? 'active' : '' }}">
        <a href="{{ url('/') }}">Home</a>
    </li>
    <li class="{{ Request::is('product') ? 'active' : '' }}">
        <a href="{{ url('product') }}">Products</a>
    </li>
    <li class="{{ Request::is('auth/login') ? 'active' : '' }}">
        <a href="{{ url('auth/login') }}">Login</a>
    </li>
</ul>

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read This 👉   Laravel 6 Set Timestamps using Eloquent Model

Summary

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

Free Live Chat for Any Issue

I hope you get an idea about PHP Laravel Set Active Menu Examples.
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.