mosweed / laravel-auto-crud
Complete CRUD scaffolding generator for Laravel 12 with API, Blade views, Livewire components, automatic routing, custom layouts, and more
Fund package maintenance!
Mosweed
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/mosweed/laravel-auto-crud
Requires
- php: ^8.2
- illuminate/console: ^11.0|^12.0
- illuminate/database: ^11.0|^12.0
- illuminate/filesystem: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
This package is auto-updated.
Last update: 2026-01-04 20:36:09 UTC
README
Laravel Auto CRUD
Generate complete CRUD scaffolding in seconds
Installation โข Quick Start โข Features โข Documentation
โก Features
| 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 |
๐ Requirements
- PHP 8.2+
- Laravel 11.x or 12.x
๐ฆ Installation
composer require mosweed/laravel-auto-crud
Publish Layout & Welcome Page
php artisan crud:layout --welcome
Publish Configuration (Optional)
php artisan vendor:publish --tag=auto-crud-config
๐ Quick Start
# 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 โจ
๐ป Usage
Basic Command
php artisan make:crud Post
This generates:
- โ Model with Filterable and Sortable traits
- โ Web Controller
- โ API Controller
- โ Form Requests (Store & Update)
- โ Policy
- โ Blade Views (index, create, edit, show)
- โ
Routes in
web.phpandapi.php
Command Options
| 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 |
Defining Fields
php artisan make:crud Post --fields="title:string,body:text,is_published:boolean"
Supported Types
| Type | Database Column |
|---|---|
string |
VARCHAR |
text |
TEXT |
integer |
INTEGER |
boolean |
BOOLEAN |
date |
DATE |
datetime |
DATETIME |
decimal |
DECIMAL |
json |
JSON |
foreignId |
BIGINT UNSIGNED |
Modifiers
--fields="title:string:255,slug:string:unique,body:text:nullable"
nullable- Field can be nullunique- Add unique constraint255- String length
Relationships
# 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
JSON Configuration
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
๐ Layout Command
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 |
Welcome Page
# Layout + welcome page together php artisan crud:layout --welcome # With Bootstrap php artisan crud:layout --css=bootstrap --welcome
๐ Filtering & Sorting
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
๐จ Tailwind v4 Colors
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; }
๐ Generated Files
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
๐ Documentation
For complete documentation, see DOCUMENTATION.md.
๐งช Testing
composer test
๐ Changelog
See CHANGELOG.md for recent changes.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ Security
If you discover any security-related issues, please open an issue on GitHub.
๐จโ๐ป Credits
๐ License
The MIT License (MIT). See LICENSE for more information.
Made with โก by Mosweed