laravel-generator maintained by adereksisusanto
Description
Generate Laravel models, migrations, and seeders from existing database tables
Author
Last update
2026/07/10 22:11
(v4.0.0)
License
Downloads
0
Tags
Laravel Generator
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.