I'm checking the routes inside my blade template, to add an active class to a specific li in 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 those 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 the route http://website/x or the route http://website/x/sobre, the active class is positioned correctly. But, if I access the http://website/x/servicos route, the class will be added in the first li and in the servicos li.
How can i handle this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire