Add Active Class with slug in laravel
I want to add an active class to my side, but the active class request is with a slug
web.php
Route::get('resource','ResourceController@index')->name('resource');
Route::get('resource/category/{category}','ResourceController@resourceByCategory')->name('category');
my resource.blade.php file
@foreach($categories as $category)
<a href="{{ route('category',$category->slug) }}" class="list-group-item list-group-item-action {{ 'category',$category->slug == request()->path() ? 'active' : '' }}">{{ $category->name }}</a>
@endforeach
Please how do i add the active class using the resquest route with the slug in laravel?
@foreach($categories as $category)
<a href="{{ route('category', $category->slug) }}"
class="list-group-item list-group-item-action {{ route('category', $category->slug) == url()->current() ? 'active' : '' }}"
>{{ $category->name }}</a>
@endforeach
Please or to participate in this conversation.