Laravel 5.5 active menu item using request

We know all that laravel is more famous as back-end like api development, admin panel etc. If you are wanted to make admin panel then you select theme like adminLT or any other bootstrap theme. When you make side bar or menu item then you have to make it active when we current on that page. like we have several link users, admins, products, items etc So when you are in products page then it should be selected product link with active class.

If you are doing using without page refresh then you can do it simply by jquery. But when you click on link page refresh so you have to make something like when page load, i mean using laravel.

However, Laravel 5 provide Request facade and using "Request::is" method we can check url patten and make it active. Here bellow give you easy example and you can simply follow that.


<li class="{{ Request::is('products*') ? 'active' : '' }}">

<a href="{!! route('products.index') !!}"><span>Products</span></a>


<li class="{{ Request::is('tags*') ? 'active' : '' }}">

<a href="{!! route('tags.index') !!}"><span>Tags</span></a>


<li class="{{ Request::is('items*') ? 'active' : '' }}">

<a href="{!! route('items.index') !!}"><span>Items</span></a>


As above example, you can make active item simply.

I hope you found your best solution....

November 14, 2017 | 6707 Viewer | Category : PHPLaravelBootstrapLaravel 5Laravel 5.5
Related Posts