Home » PHP Laravel Set Active Menu Examples

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:  Remove specific value from php array

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:  Remove null from array javascript Example

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:  [SOLVED] phpmyadmin - MySQL Error #2002 in Ubuntu

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:  how to upload images in wordpress by custom code?
  2. Read Also:  Redirect page after delay using Laravel Example
  3. Read Also:  VueJS Convert Comma separated String To Array Example
  4. Read Also:  how to check laravel version
  5. Read Also:  Angular 4 Custom Alert, Prompt, And Confirm Box
  6. Read Also:  Laravel Add active class to Nav Menu System
  7. Read Also:  Navigation Active Class using Laravel Example
  8. Read Also:  Laravel whereRaw havingRaw and orderByRaw Example
  9. Read Also:  How to create custom PHP page-Template using WordPress
  10. Read Also:  VueJS Convert Comma separated String To Array Example

Leave a Comment

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