In general, there are two main ways to use Livewire:
- You build the full project with Laravel Controllers, and use Livewire only for small dynamic elements on the pages
- You use Livewire Components instead of Laravel Controllers, with so-called Full-Page Components
The choice is yours, it's a personal preference. In this lesson, let's see how to do it with full-page components.
Routes
Instead of mapping to the Controller in the Routes files, you just need to map directly to the Livewire component.
use App\Livewire\CreatePost; Route::get('/posts/create', CreatePost::class);
Layout Files
Livewire uses Blade component as an application layout. So it needs to have a {{ $slot }}
placeholder. By default, Livewire uses...