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

v1.0.3 2026-01-01 04:09 UTC

This package is auto-updated.

Last update: 2026-01-04 20:36:09 UTC


README

Laravel Auto CRUD

Laravel Auto CRUD

Generate complete CRUD scaffolding in seconds

Website

Tests Latest Version Downloads License Stars

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.php and api.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 null
  • unique - Add unique constraint
  • 255 - 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.

โฌ† Back to Top

Made with โšก by Mosweed