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.

Read Also:  Laravel 5.7 Google reCAPTCHA Tutorial with Example

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.

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

Read Also:  JavaScript Image Thumbnails Preview Gallery

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 :

Read Also:  Vue IF Else Conditional Statement

Summary

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

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel Time Zone Converter(Time Difference Calculator)
  2. Read Also:  The PHP Framework Laravel installation
  3. Read Also:  PHP Generate HTML file into PDF
  4. Read Also:  Angular 9/8 Material Checkbox Examples
  5. Read Also:  Navigation Active Class using Laravel Example
  6. Read Also:  Laravel Add active class to Nav Menu System
  7. Read Also:  how to allow only 10 digit mobile number validation using javascript with jquery
  8. Read Also:  Remove Last Comma from String using jQuery
  9. Read Also:  Create WordPress Custom Admin Page
  10. Read Also:  Laravel Add active class to Nav Menu System
CLOSEX