Laravel 6 Set Active Navigation Menu Example

Today, We want to share with you Laravel 6 Set Active Navigation Menu.In this post we will show you Dynamically add active menu item in Bootstrap using Laravel 6, hear for Laravel active menu item for url included parameters we will give you demo and example for implement.In this post, we will learn about Apply Dynamic Active Class on Current Menu Item Laravel with an example.

Laravel 6 Set Active Navigation Menu

There are the Following The simple About Laravel 6 Set an Active Menu Link From Scratch Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to add dynamic Active class on selected page using Laravel 6, so the how to set bootstrap navbar class active in Laravel 6 is used for this example is following below.

How to Make Menu Item Active by URL/Route using Laravel?

  • Category
  • Menu
  • Types
  • we’re interested in is class=”active”.

  • Example 1: Exact URL in Laravel

    use helper function $request->is().

  • Example 2:Starting with the URL

    URL like /products/categories, /post/categories/edit etc.

  • Example 3: Matching URL Segment in Laravel

    laravel get URL segments

  • URL like /products/categories, /post/categories/edit etc.

    Example 4: Matching Route by Name

    routes/web.php

    Route::middleware(['auth'])->prefix('products')->name('products.')->group(function() {
        Route::resource('categories', 'Admin\CategoryController');
    });
    

    Accessing The Current Route

    Laravel 6 current, currentRouteName, and currentRouteAction methods

    $route = Route::current();
    dump($route);
    
    $name = Route::currentRouteName();
    dump($name);
    
    $action = Route::currentRouteAction();
    dump($action);
    

    we use Route::getCurrentName() method.

  • Web Programming Tutorials Example with Demo

    Read :

    Summary

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

    I hope you get an idea about Laravel 6 active menu item using request.
    I would like to have feedback on my infinityknow.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.

    Leave a Comment