Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new feature to create all database models at once / Add database schema support #65

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sebastienverreault87
Copy link

Add a new feature to create all database models at once

Change the command argument "class-name" from required to optionnal
When you do not specify a class-name, it will generate a model for every table of the database (except for the many-to-many tables, who should not have a model anyway)

Add database schema support

  • add a new option to specify the schema you generate models from (only used when you do not specify a class-name)
  • add a new option to force table name property on model to be set even for tables in the default database schema (usefull for multiple schema database who use only one connection)

Change in the many to many relationship generation

Generate a many to many relationship in model even for tables that have more than 2 columns (pivot). More code could be added to automaticaly generate the pivot.

   - force-table-name : Force tableName property to be always set in generated models
   - schema : Name of the database schema to generates models from, only used when class-name argument is not provided

Add the schema name to queries
Add schemaName and defaultSchemaName property + getter/setter in Config class
Change the condition for generating the BelongsToMany relation instead of checking if there is only 2 columns in the table, check if the primary key is made of the same columns as the two foreign keys
…ackage

- Move the code in the right class EloquentModelBuilder => EloquentModel
@hamrak
Copy link

hamrak commented Mar 7, 2022

In version 2.0.0 it's already in new command krlove:generate:models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants