Download the PHP package axn/laravel-models-generator without Composer
On this page you can find all versions of the php package axn/laravel-models-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download axn/laravel-models-generator
More information about axn/laravel-models-generator
Files in axn/laravel-models-generator
Package laravel-models-generator
Short Description Eloquent model generation from the database.
License MIT
Homepage https://github.com/AXN-Informatique/laravel-models-generator
Informations about the package laravel-models-generator
Laravel Models Generator
Generates Eloquent models and relations (belongs to, has many, has one) using DB schema.
Installation
Install the package with Composer:
In Laravel 5.5 the service provider will automatically get registered.
In older versions of the framework just add the service provider
to the array of providers in config/app.php
:
Publish config and templates (stubs) if needed using these commands:
Config is published in config/models-generator.php
Templates are published in resources/stubs/vendor/models-generator/
Modify config options and templates contents if needed.
Usage
Simply launch this command:
Options :
- --table (ou -t) : if you want to generate only certain tables. To select many tables, you can do: -t table1 -t table2 -t ...
- --preview (ou -p) : if you want to only display information messages about actions that will be done by the generator but without touching files.
Naming convention
- Model: table name in singular and studly case (cf config "singular_rules" if singularization is not done correctly).
- "has many" relation: name of the related table (plural), in camel case.
- "has one" relation: name of the related table (singular), in camel case
- "belongs to" relation: foreign key name (without "_id" or "id_"), in camel case.
Other details:
- "has many" relation: the relation name is simply the model name in camel case, so the model name should be in plural.
- "has many" and "has one" relations: if the foreign key name is not standard, a precision is concatenated to the relation name like "Via{nomFK}".
Example:
All versions of laravel-models-generator with dependencies
doctrine/dbal Version ^2.13 || ^3.1