I check the routes inside my blade template to add the active class to the one defined liin my menu with this code:
<ul>
<li class="{{ Request::is('*/sobre') || Request::is('*') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/sobre" }}">Sobre o salão</a>
</li>
<li class="{{ Request::is('*/servicos') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/servicos" }}">Serviços</a>
</li>
<li class="{{ Request::is('*/avaliacoes') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/avaliacoes" }}">Avaliações</a>
</li>
<li class="{{ Request::is('*/galeria') ? "active" : "" }}">
<a href="{{ Route::getCurrentRoute()->parameters()['domain'] . "/galeria" }}">Fotos</a>
</li>
</ul>
And these are the routes:
Route::group(['prefix' => '{domain}', 'middleware'=>'salao'], function () {
Route::get('/', 'Frontend\FrontendSalaoController@sobre');
Route::get('sobre', 'Frontend\FrontendSalaoController@sobre');
Route::get('servicos', 'Frontend\FrontendSalaoController@servicos');
Route::get('avaliacoes', 'Frontend\FrontendSalaoController@avaliacoes');
Route::get('galeria', 'Frontend\FrontendSalaoController@galeria');
});
When I access a route http://website/xor route http://website/x/sobre, the active class is positioned correctly. But, if I get access to the route http://website/x/servicos, the class will be added in the first li and in servicosli.
How can I handle this?
source
share