| Install | |
|---|---|
composer require mosweed/laravel-auto-crud |
|
| Latest Version: | v1.0.3 |
| PHP: | ^8.2 |
Generate complete CRUD scaffolding in seconds
| Feature | Description |
|---|---|
| 🏗️ Complete CRUD | Models, Controllers, Views, Routes in one command |
| 🌐 API & Web | Generate API and Web controllers simultaneously |
| 🎨 Modern Views | Tailwind v4 & Bootstrap 5 with dark mode |
| ⚡ Livewire | Real-time table and form components |
| 🛣️ Auto Routing | Routes automatically added to your files |
| 🏠 App Layout | Ready-to-use layout with navigation |
| 🎯 Tailwind v4 | Auto-detects and configures CSS variables |
| 🗑️ Soft Deletes | Full restore/force-delete support |
| 🔍 Filter & Sort | Built-in query traits |
| 🧪 Tests | Automatic Pest/PHPUnit generation |
| 📋 JSON Config | Batch generate multiple CRUDs |
| ↩️ Rollback | Auto cleanup on errors |
composer require mosweed/laravel-auto-crud
php artisan crud:layout --welcome
php artisan vendor:publish --tag=auto-crud-config
# 1. Publish layout and welcome page
php artisan crud:layout --welcome
# 2. Generate a complete CRUD
php artisan make:crud Product \
--fields="name:string,price:decimal,description:text:nullable" \
--belongsTo=Category \
--all \
--add-to-nav
# 3. Run migrations
php artisan migrate
# 4. Build assets
npm run build
Your CRUD is ready at /products ✨
php artisan make:crud Post
This generates:
web.php and api.php| Option | Description |
|---|---|
--type=api|web|both |
Output type (default: both) |
--css=tailwind|bootstrap |
CSS framework (default: tailwind) |
--all |
Generate migration, factory, seeder, and tests |
--force |
Overwrite existing files |
--soft-deletes |
Add soft delete support |
--livewire |
Generate Livewire components |
--tests |
Generate feature and unit tests |
--fields=... |
Define fields inline |
--belongsTo=Model |
Add belongsTo relationship |
--hasMany=Model |
Add hasMany relationship |
--belongsToMany=Model |
Add belongsToMany relationship |
--json=path |
Generate from JSON configuration |
--add-to-nav |
Add to navigation menu |
php artisan make:crud Post --fields="title:string,body:text,is_published:boolean"
| Type | Database Column |
|---|---|
string |
VARCHAR |
text |
TEXT |
integer |
INTEGER |
boolean |
BOOLEAN |
date |
DATE |
datetime |
DATETIME |
decimal |
DECIMAL |
json |
JSON |
foreignId |
BIGINT UNSIGNED |
--fields="title:string:255,slug:string:unique,body:text:nullable"
nullable - Field can be nullunique - Add unique constraint255 - String length# BelongsTo
php artisan make:crud Post --belongsTo=User --belongsTo=Category
# HasMany
php artisan make:crud User --hasMany=Post
# BelongsToMany
php artisan make:crud Post --belongsToMany=Tag
Create a crud.json file:
{
"models": [
{
"name": "Product",
"fields": [
{"name": "name", "type": "string"},
{"name": "price", "type": "decimal"}
],
"relationships": [
{"type": "belongsTo", "model": "Category"}
]
}
],
"options": {
"all": true,
"softDeletes": true
}
}
Run:
php artisan make:crud --json=crud.json
php artisan crud:layout
| Option | Description |
|---|---|
--css=bootstrap |
Use Bootstrap instead of Tailwind |
--force |
Overwrite existing layout |
--welcome |
Also publish welcome/dashboard page |
--models=Product |
Pre-populate navigation |
# Layout + welcome page together
php artisan crud:layout --welcome
# With Bootstrap
php artisan crud:layout --css=bootstrap --welcome
The generated models include Filterable and Sortable traits:
// Filter
GET /products?status=active
GET /products?price_from=10&price_to=100
GET /products?search=keyword
// Sort
GET /products?sort=name&direction=asc
// Soft Deletes
GET /products?trashed=1
Laravel 12 uses Tailwind v4 by default. Edit resources/css/app.css:
@theme {
/* Primary - Change to green */
--color-primary-500: #22c55e;
--color-primary-600: #16a34a;
--color-primary-700: #15803d;
/* Secondary */
--color-secondary-500: #6366f1;
--color-secondary-600: #4f46e5;
}
app/
├── Http/Controllers/
│ ├── ProductController.php
│ └── Api/ProductController.php
├── Http/Requests/Product/
│ ├── StoreProductRequest.php
│ └── UpdateProductRequest.php
├── Models/Product.php
└── Policies/ProductPolicy.php
database/
├── factories/ProductFactory.php
├── migrations/xxxx_create_products_table.php
└── seeders/ProductSeeder.php
resources/views/
├── components/app-layout.blade.php
├── welcome.blade.php
└── products/
├── index.blade.php
├── create.blade.php
├── edit.blade.php
└── show.blade.php
For complete documentation, see DOCUMENTATION.md.
composer test
See CHANGELOG.md for recent changes.
Contributions are welcome! Please feel free to submit a Pull Request.
If you discover any security-related issues, please open an issue on GitHub.
The MIT License (MIT). See LICENSE for more information.
Made with ⚡ by Mosweed