How to identify route in Laravel?

Asked

Viewed 132 times

2

I’m using a template for the menu and footer to be duplicated on every page. I put a if in the footer for when it is a given route it changes the content, but that is not what is happening, it is interpreting any and all routes as "home". If I access the route "company" it will go to the right page, but the footer will remain the same. Giving a echo Route::currentRouteName(); I only got "home".

Routes

Route::get('/', array('as' => 'home', 'uses' => 'HomeController@index'));
Route::get('home', array('as' => 'home', 'uses' => 'HomeController@index'));
Route::get('empresa', array('as' => 'empresa', 'uses' => 'EmpresaController@index'));

Template

@if(str_is('home', Route::currentRouteName()))
    <div class="pure-g">
        <div class="pure-u-1">
            <footer id="rodapeHome">
                <p id="responsabilidadeSocialHomeRodapeTexto">Responsabilidade social também é nosso foco:</p>
                <div id="empresasResponsabilidadeSocial">
                    @foreach($acaoSocial as $acaoSocial)
                        <img src="assets/images/acaosocial/{{$acaoSocial->imagem}}" />
                    @endforeach
                </div>
            </footer>       
        </div>
        <div class="pure-u-1" id="caixaDireitosAutorais">
            <p id="tituloRodapeDireitosReservados">‎© 2014 Titina Leão - Todos os direitos reservados.<p/>
        </div>
    </div>

1 answer

3


Before

Route::get('empresa', array('as' => 'home', 'uses' => 'EmpresaController@index'));

Afterward

Route::get('empresa', array('as' => 'empresa', 'uses' => 'EmpresaController@index'));

I didn’t change the as, which is the route name. Ctrl+C and Ctrl+V plus inattention = dead seal babies.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.