PHPackages                             asamaru7/eloquent-model-generator-for-lumen - 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. asamaru7/eloquent-model-generator-for-lumen

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

asamaru7/eloquent-model-generator-for-lumen
===========================================

Eloquent Model Generator

1.0.6(9y ago)141.3k↑66.7%6[2 PRs](https://github.com/asamaru7/eloquent-model-generator/pulls)MITPHP

Since Apr 3Pushed 5y ago3 watchersCompare

[ Source](https://github.com/asamaru7/eloquent-model-generator)[ Packagist](https://packagist.org/packages/asamaru7/eloquent-model-generator-for-lumen)[ RSS](/packages/asamaru7-eloquent-model-generator-for-lumen/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (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

```

Step 2. Register `GeneratorServiceProvider`:

```
$app->register(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`:

```
