In layout
@hasSection('sidebar')
@yield('sidebar')
@else
@include('sidebar')
@endif
In child where you don't want to have that sidebar
@extend('layout')
@section('sidebar', null)
@section('content')
some content
@endsection
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello every body ! let's say we have this :
layout.blade.php
@section('sidebar')
@include('sidebar')
@show
@yield('content')
sidebar.blade.php
{{ Auth::user()->full_name}}
page_for_logged_in.blade.php (for logged in users)
@extend('layout')
// the sidebar is already rendered by inheritence
@section('content')
some content
@endsection
Until here, every think is good, but for the next page (for not logged in users) :
page_for_not_logged_in.blade.php (for not logged in users)
@extend('layout')
@section('sidebar') // here i'm trying to make it empty by override
@endsection
@section('content')
some content
@endsection
But that doesn't work ! it is trying to include the sidebar file. :(
Trying to get property of non-object "full_name"
I know i can wrap it like this :
@auth
{{ Auth::user()->full_name}}
@endauth
But this is not my goal, i'm just searching for a method to implement overridable sections
Please or to participate in this conversation.