PHPackages                             saiman/laravel-saiman-crud - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. saiman/laravel-saiman-crud

ActiveLibrary[Admin Panels](/categories/admin)

saiman/laravel-saiman-crud
==========================

A modern Laravel CRUD generator for Laravel 12 &amp; 13.

v1.0.1(1mo ago)011[2 PRs](https://github.com/dev-ankitsuman/laravel-saiman-crud/pulls)MITPHPPHP ^8.2CI passing

Since Jun 27Pushed 1mo agoCompare

[ Source](https://github.com/dev-ankitsuman/laravel-saiman-crud)[ Packagist](https://packagist.org/packages/saiman/laravel-saiman-crud)[ GitHub Sponsors](https://github.com/dev-ankitsuman)[ RSS](/packages/saiman-laravel-saiman-crud/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (2)Dependencies (22)Versions (5)Used By (0)

Laravel Saiman CRUD Generator
=============================

[](#laravel-saiman-crud-generator)

 **⚡ One Command. Complete CRUD. Zero Compromise.**

 [ ![Latest Version on Packagist](https://camo.githubusercontent.com/477d7d055f155793ca2ece626d3e0b97f2c87d4da06ad9ef979ddc3f867dc15f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361696d616e2f6c61726176656c2d7361696d616e2d637275643f7374796c653d666c61742d73717561726526636f6c6f723d464632443230) ](https://packagist.org/packages/saiman/laravel-saiman-crud) [ ![Tests](https://camo.githubusercontent.com/818ceef12795caa7f8faf436f063f4fe2ca59c361382b19668e4c5d9bd826027/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465762d616e6b697473756d616e2f6c61726176656c2d7361696d616e2d637275642f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265) ](https://github.com/dev-ankitsuman/laravel-saiman-crud/actions/workflows/tests.yml) [ ![Code Style](https://camo.githubusercontent.com/8b3d8c18d33a290ee655470e6c86b2c6e49dfe11dc389af86f2571ecd1fe326a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465762d616e6b697473756d616e2f6c61726176656c2d7361696d616e2d637275642f636f64652d7374796c652e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265) ](https://github.com/dev-ankitsuman/laravel-saiman-crud/actions/workflows/code-style.yml) [ ![PHPStan](https://camo.githubusercontent.com/d791863672ad8a0f79608bf5c03a30300ece416eea2e36aec9b03e92be4cc20c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465762d616e6b697473756d616e2f6c61726176656c2d7361696d616e2d637275642f7374617469632d616e616c797369732e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265) ](https://github.com/dev-ankitsuman/laravel-saiman-crud/actions/workflows/static-analysis.yml) [ ![Total Downloads](https://camo.githubusercontent.com/dae5ff346ee591718a13b1d18d3e3a755e2b860563b2a79f0194f0b4ec97cc86/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7361696d616e2f6c61726176656c2d7361696d616e2d637275643f7374796c653d666c61742d73717561726526636f6c6f723d344634364535) ](https://packagist.org/packages/saiman/laravel-saiman-crud) [ ![PHP Version](https://camo.githubusercontent.com/c7f0a661e107c581caffe8a64774b6f3ba7e95162c1a23bb188ccebc67da5ae7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7361696d616e2f6c61726176656c2d7361696d616e2d637275643f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/saiman/laravel-saiman-crud) [ ![License](https://camo.githubusercontent.com/cb53f24b2c489ba21aca47fa845f064af308f33707929afea7c74129148f3e73/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7361696d616e2f6c61726176656c2d7361696d616e2d637275643f7374796c653d666c61742d737175617265) ](https://github.com/dev-ankitsuman/laravel-saiman-crud/blob/main/LICENSE) [ ![GitHub Stars](https://camo.githubusercontent.com/85197b3fb0f750cbef415e1299274ef260aceb5ccfed23ebb5d72dc27f8e7a01/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6465762d616e6b697473756d616e2f6c61726176656c2d7361696d616e2d637275643f7374796c653d666c61742d73717561726526636f6c6f723d464644373030) ](https://github.com/dev-ankitsuman/laravel-saiman-crud/stargazers)

 [Why?](#-why-this-package) • [Features](#-features) • [Installation](#-installation) • [Quick Start](#-quick-start) • [Usage](#-usage) • [Field Types](#-field-types) • [Architecture](#-architecture-patterns) • [Revert](#-the-revert-command) • [Config](#-configuration) • [FAQ](#-faq) • [Roadmap](#-roadmap)

---

🤔 Why This Package?
-------------------

[](#-why-this-package)

Every Laravel developer faces the same painful ritual when starting a new feature:

```
1. Create Model
2. Write Migration manually
3. Create Controller with 7 resource methods
4. Write StoreRequest with all validation rules
5. Write UpdateRequest with slightly different rules
6. Create index.blade.php, create.blade.php, edit.blade.php, show.blade.php
7. Register routes in web.php without breaking existing ones
8. Create Seeder
9. Create Factory with Faker definitions

```

**For 10 models, that is 400–600 lines of identical boilerplate. Every. Single. Project.**

Laravel Saiman CRUD Generator eliminates all of this with **one command:**

```
php artisan make:crud Product --fields="name:string,price:decimal,active:boolean"
```

Generates **10+ production-ready files instantly** — and it understands your fields.

---

✨ Features
----------

[](#-features)

FeatureDescription🚀 **One-Command Scaffolding**Model, Migration, Controller, Requests, Views, Routes, Seeder, Factory — all at once🧠 **Field-Aware Generation**26 field types with automatic migration column, validation rule, HTML input, and Faker mapping🛡️ **Smart Route Append**Routes are safely appended with CRUD markers — your existing routes are never touched🎨 **Auto Layout Detection**Uses your existing layout or generates a clean standalone fallback with inline CSS⏪ **Full Revert System**`crud:revert` drops the table, removes migration records, and deletes all generated files🔌 **Multiple Architectures**API Resources, Service Layer, Repository Pattern, Livewire, Filament — all supported🎯 **Modern Laravel Only**Built exclusively for Laravel 12 and 13 with PHP 8.2+📝 **PSR-12 Compliant Output**All generated code passes Laravel Pint automatically🔧 **Customizable Stubs**Publish and modify every stub to match your team's standards🔍 **PHPStan Compatible**Generated code has proper types, docblocks, and strict typing---

📋 Requirements
--------------

[](#-requirements)

RequirementVersion**PHP**`^8.2`**Laravel**`^12.0 || ^13.0`---

📦 Installation
--------------

[](#-installation)

Install as a **dev dependency** via Composer:

```
composer require saiman/laravel-saiman-crud --dev
```

> The package uses Laravel's auto-discovery. **No manual registration needed.**

### Publish Configuration and Stubs (Optional)

[](#publish-configuration-and-stubs-optional)

```
# Publish config only
php artisan vendor:publish --tag=saiman-crud-config

# Publish stubs only (for customization)
php artisan vendor:publish --tag=saiman-crud-stubs

# Publish everything at once
php artisan vendor:publish --tag=saiman-crud
```

---

⚡ Quick Start
-------------

[](#-quick-start)

### Step 1 — Generate CRUD

[](#step-1--generate-crud)

```
php artisan make:crud Product \
  --fields="name:string,price:decimal,stock:integer,active:boolean,description:text:nullable"
```

**What gets generated:**

```
✓ Model        → app/Models/Product.php
✓ Migration    → database/migrations/xxxx_create_products_table.php
✓ Controller   → app/Http/Controllers/ProductController.php
✓ Requests     → app/Http/Requests/StoreProductRequest.php
✓ Requests     → app/Http/Requests/UpdateProductRequest.php
✓ Views        → resources/views/products/index.blade.php
✓ Views        → resources/views/products/create.blade.php
✓ Views        → resources/views/products/edit.blade.php
✓ Views        → resources/views/products/show.blade.php
✓ Seeder       → database/seeders/ProductSeeder.php
✓ Factory      → database/factories/ProductFactory.php
✓ Routes       → Appended to routes/web.php

```

### Step 2 — Run Migration

[](#step-2--run-migration)

```
php artisan migrate
```

### Step 3 — Visit Your App

[](#step-3--visit-your-app)

```
http://127.0.0.1:8000/products

```

**Done. Your fully functional CRUD is live.**

---

📚 Usage
-------

[](#-usage)

### Basic Web CRUD

[](#basic-web-crud)

```
php artisan make:crud Post --fields="title:string,body:text,published_at:datetime:nullable"
```

### API CRUD (No Blade Views)

[](#api-crud-no-blade-views)

```
php artisan make:crud Product --api --fields="sku:string:unique,name:string,price:decimal"
```

### With Service Layer

[](#with-service-layer)

```
php artisan make:crud Order --service --fields="total:decimal,status:string"
```

### With Repository Pattern

[](#with-repository-pattern)

```
php artisan make:crud Customer \
  --repository \
  --fields="email:email:unique,name:string,phone:string:nullable"
```

### With Livewire Component

[](#with-livewire-component)

```
php artisan make:crud Task --livewire --fields="title:string,completed:boolean"
```

### With Filament Resource

[](#with-filament-resource)

```
php artisan make:crud Category \
  --filament \
  --fields="name:string,slug:string:unique,parent_id:foreignId:nullable"
```

### Full-Stack API with Clean Architecture

[](#full-stack-api-with-clean-architecture)

```
php artisan make:crud Product \
  --api \
  --service \
  --repository \
  --fields="name:string,price:decimal,sku:string:unique,active:boolean"
```

### Force Overwrite Existing Files

[](#force-overwrite-existing-files)

```
php artisan make:crud Product --force
```

### All Available Options

[](#all-available-options)

```
php artisan make:crud {Model}
    {--fields=}       # Field definitions
    {--api}           # Generate API controller and JSON resource
    {--service}       # Generate Service class
    {--repository}    # Generate Repository interface and implementation
    {--livewire}      # Generate Livewire component
    {--filament}      # Generate Filament resource
    {--force}         # Overwrite existing files
```

---

🧬 Field Types
-------------

[](#-field-types)

Define fields using this format:

```
name:type
name:type:nullable
name:type:unique
name:type:nullable:unique

```

Multiple fields are comma-separated:

```
--fields="name:string,price:decimal:nullable,email:email:unique,active:boolean"
```

### Supported Types

[](#supported-types)

TypeMigration ColumnValidation RuleHTML InputFaker Method`string``string``string|max:255``text``words(3, true)``text``text``string``textarea``paragraph()``longtext``longText``string``textarea``text()``integer` / `int``integer``integer``number``randomNumber()``bigint``bigInteger``integer``number``randomNumber()``smallint``smallInteger``integer``number``numberBetween(0, 32767)``tinyint``tinyInteger``integer|min:0|max:127``number``numberBetween(0, 127)``decimal``decimal``numeric``number``randomFloat(2, 0, 1000)``float``float``numeric``number``randomFloat(2)``double``double``numeric``number``randomFloat(4)``boolean` / `bool``boolean``boolean``checkbox``boolean()``date``date``date``date``date()``datetime``dateTime``date_format:Y-m-d H:i:s``datetime-local``dateTime()``timestamp``timestamp``date_format:Y-m-d H:i:s``datetime-local``dateTime()``time``time``date_format:H:i:s``time``time()``email``string``email:rfc,dns``email``safeEmail()``url``string``url``url``url()``password``string``string|min:8``password``bcrypt('password')``ip``ipAddress``ip``text``ipv4()``uuid``uuid``uuid``text``uuid()``json``json``array``textarea``[]``enum``enum``string``select``word()``file``string``file``file``word().'.pdf'``image``string``image|mimes:jpg,jpeg,png``file``imageUrl()``foreignId``foreignId``integer``number``1`### Field Modifiers

[](#field-modifiers)

ModifierMigration EffectValidation Effect`:nullable``->nullable()``nullable` replaces `required``:unique``->unique()``unique:table` added---

🏗️ Architecture Patterns
------------------------

[](#️-architecture-patterns)

### API Mode (`--api`)

[](#api-mode---api)

Generates an API controller under `app/Http/Controllers/Api/` and a JSON Resource:

```
// Generated API Controller
public function index(): AnonymousResourceCollection
{
    $products = Product::latest()->paginate(15);
    return ProductResource::collection($products);
}

public function store(StoreProductRequest $request): ProductResource
{
    $product = Product::create($request->validated());
    return new ProductResource($product);
}
```

Routes are appended to `routes/api.php`:

```
// CRUD-GENERATED:START Product
Route::apiResource('products', \App\Http\Controllers\Api\ProductController::class);
// CRUD-GENERATED:END Product
```

---

### Service Layer (`--service`)

[](#service-layer---service)

Generates `app/Services/ProductService.php` with clean CRUD methods:

```
class ProductService
{
    public function paginate(int $perPage = 15): LengthAwarePaginator
    {
        return Product::latest()->paginate($perPage);
    }

    public function create(array $data): Product
    {
        return Product::create($data);
    }

    public function update(Product $product, array $data): Product
    {
        $product->update($data);
        return $product->refresh();
    }

    public function delete(Product $product): bool
    {
        return (bool) $product->delete();
    }
}
```

---

### Repository Pattern (`--repository`)

[](#repository-pattern---repository)

Generates both an interface and an Eloquent implementation:

```
// ProductRepositoryInterface.php
interface ProductRepositoryInterface
{
    public function paginate(int $perPage = 15): LengthAwarePaginator;
    public function findOrFail(int $id): Product;
    public function create(array $data): Product;
    public function update(Product $product, array $data): Product;
    public function delete(Product $product): bool;
}

// ProductRepository.php
class ProductRepository implements ProductRepositoryInterface
{
    public function __construct(private readonly Product $model) {}

    // Full implementation included...
}
```

---

### Livewire (`--livewire`)

[](#livewire---livewire)

Generates a full Livewire CRUD component with pagination and modal:

```
class ProductManager extends Component
{
    use WithPagination;

    public bool $showModal = false;
    public bool $isEditing = false;

    public function openCreate(): void { ... }
    public function openEdit(int $id): void { ... }
    public function save(): void { ... }
    public function delete(int $id): void { ... }
}
```

> **Requires:** `livewire/livewire ^3.0`

---

### Filament (`--filament`)

[](#filament---filament)

Generates a complete Filament Resource with form schema and table columns auto-mapped from your field types:

```
class ProductResource extends Resource
{
    protected static ?string $model = Product::class;

    public static function form(Form $form): Form
    {
        return $form->schema([
            Forms\Components\TextInput::make('name')->required(),
            Forms\Components\TextInput::make('price')->numeric()->required(),
            Forms\Components\Toggle::make('active'),
        ]);
    }

    public static function table(Table $table): Table
    {
        return $table->columns([
            Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
            Tables\Columns\TextColumn::make('price')->sortable(),
            Tables\Columns\IconColumn::make('active')->boolean(),
        ]);
    }
}
```

> **Requires:** `filament/filament ^3.0`

---

⏪ The Revert Command
--------------------

[](#-the-revert-command)

The `crud:revert` command is unique to this package. It gives you a **complete undo** of everything `make:crud` created.

### Basic Revert

[](#basic-revert)

```
php artisan crud:revert Product
```

What happens:

```
1. ✅ Asks for confirmation (twice)
2. ✅ Drops the database table (products)
3. ✅ Removes the migration record from migrations table
4. ✅ Deletes app/Models/Product.php
5. ✅ Deletes app/Http/Controllers/ProductController.php
6. ✅ Deletes app/Http/Requests/StoreProductRequest.php
7. ✅ Deletes app/Http/Requests/UpdateProductRequest.php
8. ✅ Deletes resources/views/products/ (entire directory)
9. ✅ Deletes database/migrations/xxxx_create_products_table.php
10. ✅ Deletes database/seeders/ProductSeeder.php
11. ✅ Deletes database/factories/ProductFactory.php
12. ✅ Removes generated route block from routes/web.php

```

### Revert Options

[](#revert-options)

```
# Preview only — nothing is deleted
php artisan crud:revert Product --dry-run

# Also revert API files (controller, resource, api.php routes)
php artisan crud:revert Product --api

# Delete files but keep the database table
php artisan crud:revert Product --keep-table

# Also delete the auto-generated layout file
php artisan crud:revert Product --with-layout
```

### Safe Full Cycle

[](#safe-full-cycle)

You can now safely do this without any errors:

```
# Generate
php artisan make:crud Product --fields="name:string,price:decimal"
php artisan migrate

# Undo everything
php artisan crud:revert Product

# Generate again (no table already exists error)
php artisan make:crud Product --fields="name:string,price:decimal,sku:string:unique"
php artisan migrate
```

---

⚙️ Configuration
----------------

[](#️-configuration)

After publishing the config file (`config/saiman-crud.php`), you can customize:

```
return [

    /*
    |--------------------------------------------------------------------------
    | Namespace Configuration
    |--------------------------------------------------------------------------
    */
    'namespaces' => [
        'model'      => 'App\\Models',
        'controller' => 'App\\Http\\Controllers',
        'request'    => 'App\\Http\\Requests',
        'resource'   => 'App\\Http\\Resources',
        'service'    => 'App\\Services',
        'repository' => 'App\\Repositories',
        'factory'    => 'Database\\Factories',
        'seeder'     => 'Database\\Seeders',
        'livewire'   => 'App\\Livewire',
        'filament'   => 'App\\Filament\\Resources',
    ],

    /*
    |--------------------------------------------------------------------------
    | Path Configuration
    |--------------------------------------------------------------------------
    */
    'paths' => [
        'model'      => 'app/Models',
        'controller' => 'app/Http/Controllers',
        'request'    => 'app/Http/Requests',
        'resource'   => 'app/Http/Resources',
        'service'    => 'app/Services',
        'repository' => 'app/Repositories',
        'factory'    => 'database/factories',
        'seeder'     => 'database/seeders',
        'migration'  => 'database/migrations',
        'views'      => 'resources/views',
        'routes'     => 'routes',
    ],

    /*
    |--------------------------------------------------------------------------
    | Generation Defaults
    |--------------------------------------------------------------------------
    */
    'soft_deletes' => false,   // Add SoftDeletes to all generated models
    'timestamps'   => true,    // Include timestamps in migrations
    'pagination'   => 15,      // Default pagination count in controllers

];
```

---

🔧 Customizing Stubs
-------------------

[](#-customizing-stubs)

Publish all stubs to your project:

```
php artisan vendor:publish --tag=saiman-crud-stubs
```

This creates `stubs/saiman-crud/` in your project root:

```
stubs/saiman-crud/
├── model.stub
├── migration.stub
├── controller.stub
├── controller.api.stub
├── request.store.stub
├── request.update.stub
├── resource.stub
├── seeder.stub
├── factory.stub
├── service.stub
├── routes.web.stub
├── routes.api.stub
├── layout.stub
├── views/
│   ├── index.stub
│   ├── create.stub
│   ├── edit.stub
│   └── show.stub
├── repository/
│   ├── interface.stub
│   └── repository.stub
├── livewire/
│   ├── component.stub
│   └── view.stub
└── filament/
    └── resource.stub

```

The generator **always checks your published stubs first** before falling back to the package defaults.

**Common customizations:**

```
// Add copyright header to model.stub
