adereksisusanto/laravel-generator

Generate Laravel models, migrations, and seeders from existing database tables

Maintainers

Package info

github.com/adereksisusanto/laravel-generator

pkg:composer/adereksisusanto/laravel-generator

Transparency log

Fund package maintenance!

adereksisusanto

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v4.0.0 2026-07-10 20:11 UTC

This package is auto-updated.

Last update: 2026-07-10 20:13:21 UTC


README

PHP Laravel License Tests PHPStan 1.x 2.x 3.x 4.x Downloads

Generate Laravel models, migrations, and seeders directly from your existing database tables.

Supports MySQL, PostgreSQL, SQLite, and SQL Server. Compatible with PHP 8.3+ and Laravel 13.

Installation

composer require adereksisusanto/laravel-generator

Publish config (optional):

php artisan vendor:publish --provider="Adereksisusanto\Laravel\Generator\ServiceProvider" --tag=config

Commands

# Generate all (models + migrations + seeders)
php artisan generate

# Individual generators
php artisan generate:model
php artisan generate:migration
php artisan generate:seeder

Options

# Specific tables
php artisan generate:model --tables=users,posts

# Custom namespace (model only)
php artisan generate:model --namespace="App\Models"

# Record limit (seeder only, 0 = unlimited)
php artisan generate:seeder --limit=50

# Overwrite existing files
php artisan generate:model --force

# Custom connection
php artisan generate:model --connection=mysql

# Also generate migration and/or seeder with model
php artisan generate:model --tables=users -m
php artisan generate:model --tables=users -s
php artisan generate:model --tables=users -ms

Combined command flags (generate)

Flag Description
--model-only Generate only models
--migration-only Generate only migrations
--seeder-only Generate only seeders
--seeder-limit Max seed records (0 = unlimited)

What Gets Generated

Models

Eloquent model with $fillable, $casts, $hidden, relationships (belongsTo/hasMany), HasFactory trait, and SoftDeletes trait when deleted_at column exists.

Migrations

Schema::create() with proper column types, nullable, unsigned, defaults, and indexes.

Seeders

Model::insert([...]) populated with actual data from your database table.

Configuration

// config/generator.php

'tables' => [
    'includes' => [],
    'excludes' => ['migrations', 'failed_jobs'],
],
'paths' => [
    'model' => app_path('Models'),
    'migration' => database_path('migrations'),
    'seeder' => database_path('seeders'),
],
'model' => [
    'timestamps' => true,
    'soft_deletes' => false,
    'relationships' => true,
],
'seeder' => [
    'limit' => 100,
],

Contributing

See CONTRIBUTING for contribution guidelines.

Changelog

See CHANGELOG for recent changes.

License

The MIT License (MIT). See LICENSE for more information.