根据路线删除@include [英] Remove @include depending on the route
本文介绍了根据路线删除@include的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个菜单部分,其中包括一个输入搜索栏.但是我不希望搜索栏在所有页面上都是可见的,仅适用于两个特定的uri´s.有没有办法删除刀片中包含的内容?
I have a menu partial, that includes a input search bar. But i don't want the search bar to be visibel on all pages, only for two specific uri´s. Is there a way to remove that include in blade?
当前看起来像这样:
<a href="{{ route('all') }}">all</a>
<a href="{{ route('nes') }}">nes</a>
<a href="{{ route('snes') }}">snes</a>
@include('partials._search')
我在想类似的东西
<a href="{{ route('all') }}">all</a>
<a href="{{ route('nes') }}">nes</a>
<a href="{{ route('snes') }}">snes</a>
@if($url)
@include('partials._search')
@endif
推荐答案
使用is()
方法:
@if (request()->is($url))
@include('partials._search')
@endif
或者,如果您知道路线名称:
Or if you know route name:
@if (request()->route()->getName() === $routeName)
@include('partials._search')
@endif
这篇关于根据路线删除@include的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文