Laravel - active menu

0

I'm trying out for the first time to develop a test website using Laravel and I'm following a video tutorial on youtube. Everything is going relatively well, but I have a small question that needed your help.

I have a menu with 6 buttons:

li class="principal {{ Request::is('pt/sport/homepage') ? "active" : "" }}"><a href="#">HOMEPAGE</a></li

li class="principal {{ Request::is('pt/sport/quem-somos') ? "active" : "" }}"><a href="#">QUEM SOMOS</a></li

li class="principal {{ Request::is('pt/sport/projetos', 'pt/sport/projetos/$projetoSlug') ? "active" : "" }}"><a href="#">PROJETOS</a></li

li class="principal {{ Request::is('pt/sport/produtos') ? "active" : "" }}"><a href="#">PRODUTOS</a></li

li class="principal {{ Request::is('pt/sport/metodologia') ? "active" : "" }}"><a href="#">METODOLOGIA</a></li

li class="principal {{ Request::is('pt/sport/contatos') ? "active" : "" }}"><a href="#">CONTATOS</a></li

The active state is working perfectly, but in the "Projects" and "Products" pages there will be a photo grid, which in turn, when clicking on one of the photos, will go to an individual project presentation page or product. Until everything is ok.

My question is this: When I click on Projects, my photos grid appears and the button stays active, but after clicking the photo to open the project individually (who has a photo gallery) the projects button is no longer active.

How do I keep the "Projects" button active?

    
asked by anonymous 12.06.2018 / 23:40

1 answer

0

In order to get the active class effect I use the following, it's a bit laborious, but how do I use the NAV and then use the @extends ('nav') and the other @section.

<li class="{{ request()->is('/') ? 'active' : '' }}"><a href="{{asset('/')}}"><i class="icon-dashboard"></i><span>Página Inicial</span> </a> </li>
            <li class="{{ request()->is('atendimentos') ? 'active' : '' }} {{ request()->is('atendimentos/create') ? 'active' : '' }} {{ request()->is('atendimentos/*/edit') ? 'active' : '' }}"><a href="{{asset('atendimentos')}}"><i class="icon-list-alt"></i><span>Atendimentos</span> </a> </li>
            <li class="{{ request()->is('pessoas') ? 'active' : '' }} {{ request()->is('pessoas/create') ? 'active' : '' }} {{ request()->is('pessoas/*/edit') ? 'active' : '' }}"><a href="{{asset('pessoas')}}"><i class="icon-group"></i><span>Pessoas</span> </a></li>
            <li class="{{ request()->is('financeiro') ? 'active' : '' }} {{ request()->is('financeiro/create') ? 'active' : '' }} {{ request()->is('financeiro/*/edit') ? 'active' : '' }}"><a href="{{asset('financeiro')}}"><i class="icon-money"></i><span>Financeiro</span> </a></li>
    
13.06.2018 / 15:09