Download the PHP package colorgreen/laravel-model-generator without Composer
On this page you can find all versions of the php package colorgreen/laravel-model-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download colorgreen/laravel-model-generator
More information about colorgreen/laravel-model-generator
Files in colorgreen/laravel-model-generator
Informations about the package laravel-model-generator
Laravel model generator
Simple generator base on laracademy/generators, extending model generation. Generates model like in Yii framework. Create or update model base on existing table.
Create BaseModel and Model. If there are changes on table schema, regenerating models (by the same command as first generation) process will affect only BaseModel (new rules, fields, etc), so write your logic in Model class to prevent it from overriding.
Also base relations are generated to the models (relation and ).
Column will generate relation to itself, available by
Base
or use model validation in api controller, example store action
Example 'BaseModel'
Installation
Usage
cgenerator:modelfromtable
This command will read your database table and generate a model based on that table structure. The fillable fields, casts, dates and even namespacing will be filled in automatically.
You can use this command to generate a single table, multiple tables or all of your tables at once.
- --name=
- Use this for custom model name. Default is table name in studle_case and singular. E.g. --name=Page when table name is 'pages' and you want to name your model .
- If you use this command provide also one table in --table.
- --table=
- This parameter if filled in will generate a model for the given table.
- You can also pass in a list of tables using comma separated values.
- --base=
- Use if you want to have custom BaseModel. E.g. --base=\App\Models\MyBaseModel.
- --prefix=
- Set prefix of tables. E.g table 'cms_user_permissions' generate model 'UserPermission'
- Note that using --prefix option with --all will generate models only for tables that starts from prefix
- --all
- If this flag is present, then the table command will be ignored.
- This will generate a model for all tables found in your database.
- If --prefix is set relations will be made only within prefixed tables
- --connection=
- by default if this option is omitted then the generate will use the default connection found in
config/database.php
- To specify a connection ensure that it exists in your
config/database.php
first.
- by default if this option is omitted then the generate will use the default connection found in
- --folder=
- by default all models are store in your app/ directory. If you wish to store them in another place you can provide the relative path from your base laravel application.
- please see examples for more information
- --namespace=
- by default all models will have the namespace of App
- you can change the namespace by adding this option
- --debug
- this shows some more information while running
Examples
Generating a single table
Will generate model with name User
Generating a single table with custom model name
Generating a multiple tables
Generating all tables
Generating models from prefixed tables tables
For tables: blog_posts, blog_comments, shop_products, users, command
will generate models only for blog_posts and blog_comments, model Post
and Comment
Changing to another connection found in database.php
and generating models for all tables
Changing the folder where to /app/Models
Credits
Based on Laracadeny Generators
License
Free to use