Download the PHP package macromindonline/eloquent-model-generator without Composer
On this page you can find all versions of the php package macromindonline/eloquent-model-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download macromindonline/eloquent-model-generator
More information about macromindonline/eloquent-model-generator
Files in macromindonline/eloquent-model-generator
Package eloquent-model-generator
Short Description Eloquent Model Generator
License MIT
Informations about the package eloquent-model-generator
Eloquent Model Generator for lumen
Eloquent Model Generator is a tool based on Code Generator for generating Eloquent models.
Installation
Step 1. Add Eloquent Model Generator to your project:
Step 2. Register GeneratorServiceProvider
:
Step 3. Configure your database connection.
Usage
Use
to generate a model class. Generator will look for table with name users
and generate a model for it. You can specify another table name by supplying table-name
option:
In this case generated model will contain protected $table = 'user'
property.
Generated file will be saved into app
directory of your application and have App
namespace. If you want to change the destination and namespace, supply the output-path
and namespace
options respectively:
By default generated class will be extended from Illuminate\Database\Eloquent\Model
. To change the base class specify base-class-name
option:
There are several useful options for defining several model's properties:
no-timestamps
- addspublic $timestamps = false;
property to the modeldate-format
- specifiesdateFormat
property of the modelconnection
- specifies connection name property of the model
Instead of spcifying options each time when executing the command you can create a config file with your own default values and pass it by specifying config
option. Generator already contains its own config file at Resources/config.php
:
Its values can be overrided by your own config (e.g. <your-base-dir>/config/eloquent_model_generator.php
):
Usage example
Table user
:
Command:
Result: