Blade conditional extends

2019-07-09 04:33发布

问题:

I know this seems like an answered question, but it is not (I hope).

What I looking for is a way to extends or NOT a view: if the request is an ajax call the view does not extends nothing. Something like:

@if(!Request::ajax())

    @extends('navbar')

       @section('home')
          <div>"my content"</div>
       @stop

@else

    <div>"my content"</div>

@endif

This is NOT what I looking for:

@extends((( Request::ajax()) ? 'layouts.ajax' : 'layouts.default' ))

I mean if the request is an ajax call, I want the view do not extend nothing.

Hope to be clear.

Thx!

回答1:

Solved using the @include statement