Read up regarding Laravel 7 view components. None of this is Livewire related.
Laravel livewire how to use slot and @yield ?
I am giving a try to laravel8 with livewire. I could manage to achieve registration and login making 2 livewire components register and logger. I use a layout that is very simple at the moment but I am stuck because I don't really understand the use of @yield('content') vs the use of slot. Here is my layout :
<html>
<head>
@livewireStyles
<link rel="stylesheet" href="/css/app.css">
</head>
<body class=" bg-gradient-to-tr from-jbodyleft via-green-900 to-jbodyleft">
<div class="bg-blue-300 text-2xl h-10 text-center my-14">
@if( auth()->user())
{{auth()->user()->firstname}} {{auth()->user()->familyname}} est connecté
@endif
</div>
{{ $slot }}
<div class="bg-blue-300 text-2xl h-10 text-center my-14">
This is the footer
</div>
@livewireScripts
</body>
</html>
My routes are :
Route::get('/', function () {
return view('home');
})->name('home');
Route::get('/register',App\Http\Livewire\Auth\Register::class)->name('register');
Route::get('/login',App\Http\Livewire\Auth\Logger::class)->name('login');
Route::get('/logout', function(){ Auth::logout();})->name('logout');
and the home.blade.php is
@extends('layouts.app')
@section('content')
<div class=" flex items-center w-content m-auto p-32 text-4xl">Hello ! I am the home page !</div>
@endsection
with the layout as it is described before, I correctly display the register and logger pages but not the home page. If I change {{$slot}} with @yield('content') I correctly display the home page but not the register and logger pages. Should I use 2 different layouts ?
Please or to participate in this conversation.