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.
Example:
<li class="{{ Request::is('products*') ? 'active' : '' }}">
<a href="{!! route('products.index') !!}"><span>Products</span></a>
</li>
<li class="{{ Request::is('tags*') ? 'active' : '' }}">
<a href="{!! route('tags.index') !!}"><span>Tags</span></a>
</li>
<li class="{{ Request::is('items*') ? 'active' : '' }}">
<a href="{!! route('items.index') !!}"><span>Items</span></a>
</li>
As above example, you can make active item simply.
I hope you found your best solution....
Do you like below Tutorials ?
- Laravel 5.6 - Collection could not be converted to int
- Laravel - How to generate secure https URL from route?
- Laravel - Vue JS File Upload Example
- How to get last 7 days data in Laravel?
- Laravel Validation required if other field empty example
- Laravel Eloquent - When Case Statement in Select Query Example
- Laravel 7.x and 6.x Passing Variable to Javascript Example
- How to pass PHP variables in JavaScript or jQuery?