azizizaidi/crud_generator

CRUD generator for lazy laravel developer

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Language:Blade

Type:project

pkg:composer/azizizaidi/crud_generator

dev-main 2026-01-08 11:08 UTC

This package is auto-updated.

Last update: 2026-01-08 11:10:26 UTC


README

A comprehensive CRUD generator for Laravel 12 projects using the TALL Stack (TailwindCSS, AlpineJS, Livewire, Laravel).

Features

  • Full CRUD Operations: Create, Read, Update, Delete
  • Relationships Support: BelongsTo, HasMany, BelongsToMany
  • Pagination: Built-in pagination support
  • Sorting: Click column headers to sort
  • Search: Real-time search with debounce
  • Validation: Server-side validation rules
  • Soft Deletes: Built-in soft delete support
  • Filament Forms: Beautiful form components
  • Customizable: Easy to modify generated code

Installation

  1. Copy the CrudGenerateCommand.php to your Laravel project:

    cp app/Console/Commands/CrudGenerateCommand.php your-laravel-project/app/Console/Commands/
  2. Register the command in app/Console/Kernel.php:

    protected $commands = [
        Commands\CrudGenerateCommand::class,
    ];
  3. Run the command to verify:

    php artisan list

Usage

Basic CRUD Generation

php artisan crud:generate Post \
  --fields="title:string,content:text,status:boolean"

With Relationships

php artisan crud:generate Product \
  --fields="name:string,price:decimal:10:2,category_id:unsignedBigInteger" \
  --relationships="category:belongsTo:App\Models\Category"

With Custom Table Name

php artisan crud:generate Article \
  --table="cms_articles" \
  --fields="title:string,body:text"

Field Types Supported

Type Migration Method Example
string $table->string() title:string
text $table->text() description:text
integer $table->integer() quantity:integer
unsignedBigInteger $table->unsignedBigInteger() author_id:unsignedBigInteger
decimal $table->decimal(precision, scale) price:decimal:10,2
boolean $table->boolean() is_active:boolean
date $table->date() published_date:date
datetime $table->dateTime() created_at:datetime
json $table->json() metadata:json
enum $table->enum(values) status:enum:active,inactive

Field Modifiers

Add modifiers after the type:

  • nullable - Makes the field nullable
  • optional - Same as nullable
  • unique - Adds unique constraint

Example:

--fields="email:string:unique:nullable,title:string"

Relationship Types

BelongsTo (One-to-Many inverse)

--relationships="author:belongsTo:App\Models\Author"

Generates:

  • Foreign key column author_id
  • BelongsTo relationship in model
  • Select dropdown in form

HasMany (One-to-Many)

--relationships="comments:hasMany:App\Models\Comment"

BelongsToMany (Many-to-Many)

--relationships="tags:belongsToMany:App\Models\Tag"

Generates:

  • Pivot table post_tag
  • BelongsToMany relationship in model
  • Multi-select in form

Generated Files

For a Post resource, the generator creates:

app/
├── Models/
│   └── Post.php
├── Livewire/
│   └── Post/
│       ├── Index.php
│       └── Form.php
routes/
│   └── posts.php
resources/
└── views/
    └── livewire/
        └── posts/
            ├── index.blade.php
            └── form.blade.php
database/migrations/
    └── *_create_posts_table.php

Integration Steps

After running the generator:

1. Run Migrations

php artisan migrate

2. Include Routes

In routes/web.php:

require __DIR__.'/posts.php';

3. Add Navigation Menu

Add to your admin layout navigation:

<x-nav-link href="{{ route('posts.index') }}" :active="request()->routeIs('posts.*')">
    Posts
</x-nav-link>

4. Set Up Policies (Optional)

Create a policy for authorization:

php artisan make:policy PostPolicy --model=Post

Then register it in AuthServiceProvider.

Customization

Modifying Form Fields

Edit app/Livewire/{Resource}/Form.php:

public function form(Form $form): Form
{
    return $form->schema([
        Grid::make(2)->schema([
            TextInput::make('title')
                ->label('Post Title')
                ->required()
                ->maxLength(255),
            // Add more fields...
        ]),
    ]);
}

Modifying Table Columns

Edit app/Livewire/{Resource}/Index.php:

public function getTableColumns(): array
{
    return [
        ['name' => 'title', 'label' => 'Title', 'sortable' => true, 'searchable' => true],
        // Add more columns...
    ];
}

Adding Filters

Edit app/Livewire/{Resource}/Index.php:

public function getTableFilters(): array
{
    return [
        // Add select filters
        SelectFilter::make('category')
            ->relationship('category', 'name')
            ->searchable(),
    ];
}

Requirements

  • Laravel 12.x
  • PHP 8.2+
  • Livewire 3.x
  • TailwindCSS 3.x
  • AlpineJS 3.x
  • Filament Forms 3.x

License

MIT License