Skip to content

MuhammadSyahmi98/migration-eloquent-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database to Model

A Laravel package to generate models and migrations from existing database structure. This package allows you to reverse engineer your database into Laravel models and migrations, making it easier to work with existing databases or to create a backup of your database structure.

Installation

You can install the package via composer:

composer require syahmi-jalil/database-to-model

The package will automatically register its service provider.

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=database-to-model-config

This will create a config/database-to-model.php file where you can configure:

  • Tables to ignore when generating models and migrations
  • Default paths for generated files
  • Maximum number of columns per migration file

Usage

Generate models and migrations for all tables:

php artisan generate:models-migrations

Available Options

  • --tables: Specific tables to generate (comma-separated)
  • --connection: Database connection to use (defaults to your default connection)

Examples

Generate for specific tables:

php artisan generate:models-migrations --tables=users,products,orders

Use a different database connection:

php artisan generate:models-migrations --connection=mysql

Features

  • Automatically generates models with proper relationships
  • Creates migrations that match your existing database structure
  • Handles foreign key constraints properly
  • Sorts tables by dependencies to ensure proper migration order
  • Customizable through configuration

Requirements

  • PHP ^8.0
  • Laravel ^9.0|^10.0|^11.0

Author

About

Laravel package to generate models and migrations from existing database structure

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages