Ad

How Not To Show On A Page Of Chunk Of Layout?

- 1 answer

I have a common layout to all pages in it, I do include "form search" (search in the header). But on the page "global search" I would not like to display the search.

How to do it nicely? Check the title or route, the only thing that came to mind

Layout -> include (search.form) -> Page 
Ad

Answer

I think your best option here is to utilise Route::is($name) in your view. This allows you to check if a certain route is being accessed, it does require the use of a named route, however.

routes.php

Route::get('/search', ['uses' => '[email protected]', 'as' => 'global-search']);

View

@if ( ! Route::is('global-search'))

    @include('search.form')

@endif
Ad
source: stackoverflow.com
Ad