How to work with slots in Laravel Blade files
Categorized as Laravel
To check if a $slot
has some content, this doesn’t work because $slot
is an object and will always be true.
<div>
{{ $slot ?: 'Default' }}
</div>
Use different methods on the $slot
object instead. See Illuminate\View\ComponentSlot
.
<div>
{{ $slot->isNotEmpty() ? $slot : 'Default' }}
</div>