utkarshgayguwal/laravel-smart-scaffold

Generate complete Laravel CRUD operations with a single command, including models, controllers with actual code having error handling, migrations, requests, factories, resources, and routes - ready for immediate API testing in Postman

v1.5.0 2025-05-14 17:34 UTC

README

Latest Version License Total Downloads PHP Version

🚀 Generate complete Laravel CRUD operations with a single command! Smart Scaffold automatically creates all necessary components including models, controllers, migrations, requests, factories, resources, filters, and routes - ready for immediate API testing.

🚀 Why Choose Smart Scaffold?

  • Instant Development - Get your API endpoints working in minutes
  • 🛡 Production-Ready Code - Built-in error handling and validation
  • 🎯 Complete API Stack - Everything you need for RESTful APIs
  • 🤖 Smart Generation - Automatic relationships and field detection
  • 🔍 Built-in Filtering - Auto-generated filter classes for all models
  • 📦 API Resources - Clean JSON response formatting

✨ Key Features

📦 Complete CRUD Stack

  • Models with HasFactory, SoftDeletes and filtering support
  • Controllers with full CRUD methods and error handling
  • Migrations with smart field type detection
  • Factories with intelligent Faker data generation
  • Requests with strict validation (all fields required)
  • Resources for standardized API responses (ID-first format)
  • Filters for advanced query filtering
  • Routes automatically added to routes/api.php

🔥 Advanced Features

  • Smart Relationships - Automatic foreign key detection
  • Type-Aware Filtering - Different logic per field type
  • Standardized Responses - Consistent JSON API format
  • Field Modifiers - nullable, default, unique, index, cascade
  • Postman Integration - Ready-to-use API endpoints

🛠️ Field Types & Modifiers

Type Description Example
string VARCHAR name:string
text TEXT content:text
integer INT quantity:integer
decimal DECIMAL price:decimal:precision(8,2)
boolean TINYINT(1) is_active:boolean
foreign Creates relationship user_id:foreign:users:id
Modifier Example Result
nullable bio:text:nullable $table->text('bio')->nullable()
default(value) status:string:default(draft) $table->string('status')->default('draft')
unique email:string:unique $table->string('email')->unique()
index slug:string:index $table->string('slug')->index()
cascade user_id:foreign:cascade Adds ->onDelete('cascade')

🛠 Installation

# Install via Composer
composer require utkarshgayguwal/laravel-smart-scaffold

# Run the publish command (optional)
php artisan vendor:publish --provider="UtkarshGayguwal\SmartScaffold\Providers\SmartScaffoldServiceProvider"

💻 Usage Examples

Basic CRUD Generation

# Generate a Category model with name and description
php artisan make:crud Category --fields='name:string,description:text'; 

Advanced Field Types

# Generate with various field types and modifiers
php artisan make:crud Product \
  --fields="
    name:string:required:max:255,
    description:text:nullable,
    price:decimal:default(0),
    stock:integer:default(0),
    category_id:foreign:categories:id:cascade
  "

🚀 Quick Start

  1. Install the package:
composer require utkarshgayguwal/laravel-smart-scaffold
  1. Generate a CRUD:
php artisan make:crud User --fields="email:string:unique,password:string"
  1. Test in Postman:
  • GET /api/products - List all users
  • POST /api/products - Create a new user
  • GET /api/products/{id} - View a user
  • POST /api/products/{id}?_method=PUT - Update a user
  • DELETE /api/products/{id} - Delete a user

📝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

📄 License

This package is open-sourced software licensed under the MIT license.