laravel - Livewire 2.2: Undefined variable slot in app.blade.php
Solution:
Since you're using the @section
directive (where you @extend
a layout, and use sections), and not the component $slot
approach (see https://laravel.com/docs/8.x/blade#slots), you should be using @yield
instead of echoing the "special" $slot
variable.
Alternatively you could go with the slots-approach, but you would generally choose one or the other. Going with that approach means a different structure to your blade files, and there's nothing wrong with either way -- just be consistent about which one you choose.
To continue using sections and extending layouts, simply replace {{ $slot }}
with @yield('content')
, like
<div class="container">
@yield('content')
</div>
Answer
Solution:
If you still want to use slot
please create component php artisan make:component Layouts/Login
and on render function in Livewire controller Http/Livewire/...
add layout
public function render()
{
return view('livewire.pages.login')
->layout('components.layouts.login');
}
Answer
Solution:
instead of
@extends('layouts.app')
I found that laravel 10 uses x-app-layout
<x-app-layout>
Some content here...
</x-app-layout>
Source