How to Build a Laravel 12 CRUD Application with Livewire
Introduction
In this tutorial, you’ll learn how to build a complete CRUD (Create, Read, Update, Delete) application in Laravel 12 using Livewire — a full-stack framework that makes building modern, reactive web apps simple and elegant without leaving the comfort of Laravel.
Requirements
-
PHP >= 8.1
-
Composer
-
Laravel 12
-
Node.js & npm (optional for styling)
-
Basic Laravel knowledge
Step 1: Create a New Laravel Project
Step 2: Install Livewire
Install Livewire using Composer:
Step 3: Include Livewire Assets
Edit your layout file at resources/views/layouts/app.blade.php
:
Step 4: Create Post Model and Migration
Edit the migration file:
Step 5: Configure Database
In your .env
file:
Then run the migration:
Step 6: Create Livewire Component
Step 7: Open Your Post
Model
File: app/Models/Post.php
Add the $fillable
property like this:
Step 8: Add Livewire Component Logic
Edit app/Livewire/PostCrud.php
:
Step 9: Create the View
Create the file:
resources/views/livewire/post-crud.blade.php
Step 10: Add Route
Update routes/web.php
:
Step 11: Run the App
Open your browser at:
👉 http://localhost:8000
You should see the Livewire CRUD interface!
Optional Enhancements
-
Style with Bootstrap/Tailwind CSS
-
Add pagination using
WithPagination
Livewire trait -
Use modals for editing/creating
-
Add search and filters
Conclusion
You now have a fully functional Laravel 12 CRUD application powered by Livewire. This approach makes it easy to build dynamic UIs without writing any custom JavaScript.