PHPackages                             macromindonline/eloquent-model-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. macromindonline/eloquent-model-generator

ActiveLibrary[Database &amp; ORM](/categories/database)

macromindonline/eloquent-model-generator
========================================

Eloquent Model Generator

1.0.6(9y ago)014MITPHP

Since Apr 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/macromindonline/eloquent-model-generator)[ Packagist](https://packagist.org/packages/macromindonline/eloquent-model-generator)[ RSS](/packages/macromindonline-eloquent-model-generator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

Eloquent Model Generator for lumen
==================================

[](#eloquent-model-generator-for-lumen)

Eloquent Model Generator is a tool based on [Code Generator](https://github.com/krlove/code-generator) for generating Eloquent models.

Installation
------------

[](#installation)

Step 1. Add Eloquent Model Generator to your project:

```
composer require asamaru7/eloquent-model-generator-for-lumen --dev

```

Step 2. Register `GeneratorServiceProvider`:

```
'providers' => [
    // ...
    Krlove\EloquentModelGenerator\Provider\GeneratorServiceProvider::class,
];
```

Step 3. Configure your database connection.

Usage
-----

[](#usage)

Use

```
php artisan krlove:generate:model User

```

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:

```
php artisan krlove:generate:model User --table-name=user

```

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:

```
php artisan krlove:generate:model User --output-path=/full/path/to/output/directory --namespace=Some\\Other\\NSpace

```

By default generated class will be extended from `Illuminate\Database\Eloquent\Model`. To change the base class specify `base-class-name` option:

```
php artisan krlove:generate:model User --base-class-name=Some\\Other\\Base\\Model

```

There are several useful options for defining several model's properties:

- `no-timestamps` - adds `public $timestamps = false;` property to the model
- `date-format` - specifies `dateFormat` property of the model
- `connection` - 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`:

```
