有没有办法 "exclude" 来自 @include('') 包含的特定视图的元素

Is there a way to "exclude" an element from specific view included with @include('')

所以在 app.blade.php 中,我是 including 带有 html 的片段,这实际上是我的页脚:

</body>



    @include('inc.ftr')



</html>

不过,我想在没有此页脚的情况下加载特定视图,它会自动包含在每个视图中。

有没有办法在视图级别将其排除?

方法有很多种。您可以检查 URI。例如,如果您想要包含除 admin/* URI 之外的所有请求的视图:

@unless (request()->is('admin/*'))
    @include('inc.ftr')
@endunless

或者您可以检查特定的路线名称:

@unless (Route::currentRouteName() === 'some.route')
    @include('inc.ftr')
@endunless