Giter Club home page Giter Club logo

eloquent-model-generator's Introduction

Eloquent Model Generator

Eloquent Model Generator generates Eloquent models using database schema as a source.

Version 2.0.0

Version 2.0.0 has been released. Checkout this discussion for more details and upgrade instructions.

Installation

Step 1. Add Eloquent Model Generator to your project:

composer require krlove/eloquent-model-generator --dev

Step 2. Register GeneratorServiceProvider:

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

Step 3. Configure your database connection.

Usage

Use

php artisan krlove:generate:model User

to generate a model class. Generator will look for table named users and generate a model for it.

table-name

Use table-name option to specify another table name:

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

In this case generated model will contain protected $table = 'user' property.

output-path

Generated file will be saved into app/Models directory of your application and have App\Models namespace by default. 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=Your\\Custom\\Models\\Place

output-path can be absolute path or relative to project's app directory. Absolute path must start with /:

  • /var/www/html/app/Models - absolute path
  • Custom/Models - relative path, will be transformed to /var/www/html/app/Custom/Models (assuming your project app directory is /var/www/html/app)

base-class-name

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=Custom\\Base\\Model

no-backup

If User.php file already exist, it will be renamed into User.php~ first and saved at the same directory. Unless no-backup option is specified:

php artisan krlove:generate:model User --no-backup

Other options

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

Overriding default options

Instead of specifying options each time when executing the command you can create a config file named eloquent_model_generator.php at project's config directory with your own default values:

<?php

return [
    'namespace' => 'App',
    'base_class_name' => \Illuminate\Database\Eloquent\Model::class,
    'output_path' => null,
    'no_timestamps' => null,
    'date_format' => null,
    'connection' => null,
    'no_backup' => null,
    'db_types' => null,
];

Registering custom database types

If running a command leads to an error

[Doctrine\DBAL\DBALException]
Unknown database type <TYPE> requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

it means that you must register your type <TYPE> at your config/eloquent_model_generator.php:

return [
    // ...
    'db_types' => [
        '<TYPE>' => 'string',
    ],
];

Usage example

Table user:

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `role_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `user_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Command:

php artisan krlove:generate:model User

Result:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * @property int $id
 * @property int $role_id
 * @property mixed $username
 * @property mixed $email
 * @property Role $role
 * @property Article[] $articles
 * @property Comment[] $comments
 */
class User extends Model
{
    /**
     * @var array
     */
    protected $fillable = ['role_id', 'username', 'email'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function role()
    {
        return $this->belongsTo('Role');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function articles()
    {
        return $this->hasMany('Article');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function comments()
    {
        return $this->hasMany('Comment');
    }
}

Generating models for all tables

Command krlove:generate:models will generate models for all tables in the database. It accepts all options available for krlove:generate:model along with skip-table option.

skip-table

Specify one or multiple table names to skip:

php artisan krlove:generate:models --skip-table=users --skip-table=roles

Note that table names must be specified without prefix if you have one configured.

Customization

You can hook into the process of model generation by adding your own instances of Krlove\EloquentModelGenerator\Processor\ProcessorInterface and tagging it with GeneratorServiceProvider::PROCESSOR_TAG.

Imagine you want to override Eloquent's perPage property value.

class PerPageProcessor implements ProcessorInterface
{
    public function process(EloquentModel $model, Config $config): void
    {
        $propertyModel = new PropertyModel('perPage', 'protected', 20);
        $dockBlockModel = new DocBlockModel('The number of models to return for pagination.', '', '@var int');
        $propertyModel->setDocBlock($dockBlockModel);
        $model->addProperty($propertyModel);
    }

    public function getPriority(): int
    {
        return 8;
    }
}

getPriority determines the order of when the processor is called relative to other processors.

In your service provider:

public function register()
{
    $this->app->tag([InflectorRulesProcessor::class], [GeneratorServiceProvider::PROCESSOR_TAG]);
}

After that, generated models will contain the following code:

/**
 * The number of models to return for pagination.
 * 
 * @var int
 */
protected $perPage = 20;

eloquent-model-generator's People

Contributors

jimmorrison723 avatar krlove avatar tiamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eloquent-model-generator's Issues

Custom Primary Key

Hey there,

I used custom primarykey name instead of id in my tables.
In Eloquent we used public $primaryKey property to set primarykey name to match in the table.
But it seems your generator doesn't generate public $primaryKey = "{{ custom_primarykey_name }}";

It would be awesome if you have this feature.

Thank you,
Regards

Unable to create pivot tables with attributes

In line 91 of Processor/RelationProcessor a table is recognized as pivotat for a many to many relations (and then included as belongToMany) only if it only has 2 columns.
This makes impossible to store attributes on relation:

if (count($foreignKeys) === 2 && (count($table->getColumns()) === 2))

What about considering a table pivot also if it has exactly 2 primary keys like in

if (count($foreignKeys) === 2 && (count($table->getColumns()) === 2) or count($primaryKeys)===2)) {

Also, maybe the created_at and updated_at columns could be ignored and not counted

Lumen 5.5 Generation error

Hi,
I am using Lumen 5.5 and Php 7.1
I am trying to generate Model from my database but a got this error :

  Type error: Argument 1 passed to Krlove\EloquentModelGenerator\Provider\GeneratorServiceProvider::Krlove\EloquentModelGenerator\Provider\{closure}() must be an instance of Krlove\EloquentModelGenerator\Provid  
  er\Krlove\EloquentModelGenerator\Provider\Illuminate\Foundation\Application, instance of Laravel\Lumen\Application given, called in  vendor/laravel/framework/src/Illuminate/Container/  
  Container.php on line 749    

Can you help please ?
Thank you

Can't generate a model from a view

It can be easily done modifying the name check in ExistenceCheckerProcessor

public function process(EloquentModel $model, Config $config)
{
    $schemaManager = $this->databaseManager->connection($config->get('connection'))->getDoctrineSchemaManager();
    $prefix = $this->databaseManager->connection($config->get('connection'))->getTablePrefix();

    $currName = array($prefix . $model->getTableName());
    if (!$schemaManager->tablesExist($currName)) {
        if (!$this->viewsExist($currName, $schemaManager->listViews())) {
            throw new GeneratorException(sprintf('Table/view %s does not exist', $prefix . $model->getTableName()));
        }
    }
}

private function viewsExist($currView, $Names){
    $listViews = array();
    foreach ($Names as $currName){
        $listViews[]= strtolower($currName->getName());
    }
    $viewNames = array_map('strtolower', (array) $currView);
    return count($viewNames) === count(array_intersect($viewNames, $listViews));
}

Duplicate properties and methods for tables with more than one foreign key relation

I am not entirely sure about this, but it looks to me if table has multiple foreign key relations, generator will produce following:

<?php

/**
 * @property Child[] $children
 * @property Child[] $children
 */
class Guardian extends BaseModel
{

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function children()
    {
        return $this->hasMany(Child::class, 'toy', 'toyid');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function children()
    {
        return $this->hasMany(Child::class, 'hat', 'hatid');
    }
}

I don't know what exactly causes this output, but multiple foreign key relations is my guess.

PDOException: could not find driver in Lumen 7

I tried to run php artisan krlove:generate:model command but everytime it appears this message:

In PDOConnection.php line 31:
  could not find driver  
In PDOConnection.php line 27:
  could not find driver

DB Configuration is correct, because I can get DB results with Eloquent.

I've registered provider in app.php yet.

Lumen version I'm currently using is 7.1.0

issue with postgresql on homestead

a fresh installed laravel 5.4

run:
composer require krlove/eloquent-model-generator --dev
And added to service provider.

then run on console
php artisan krlove:generate:model User

get errors:

[Doctrine\DBAL\DBALException]
Unknown database type point requested, Doctrine\DBAL\Platforms\PostgreSQL92Platform may not support it.

Is the related Doctrine version is incorrect ?

Thanks.

Unescaped regex....

ErrorException  : preg_replace(): Unknown modifier '/'
 at /dev/urandom/vendor/krlove/eloquent-model-generator/src/Processor/RelationProcessor.php:303
    299|      * @return string
    300|      */
    301|     protected function removePrefix($prefix, $tableName)
    302|     {
  > 303|         return preg_replace("/^$prefix/", '', $tableName);
    304|     }
    305| }
    306|

Should be just string ops or preg_quote.

publish config and generates models in app/Models

Hi, I wanna commit some codes, will you accept my pull request?

  1. publish config.php to app/config
  2. change the default output-path to app/Models
  3. change the default namespace to App\Models
  4. remove timestamps fields from $fillable
  5. change krlove:generate:model to make:kmodel
  6. add $casts property to models

Installing via composer remove lumen

$ composer require krlove/eloquent-model-generator
Using version ^1.2 for krlove/eloquent-model-generator
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 11 installs, 1 update, 21 removals

  • Removing illuminate/contracts (v5.5.28)
  • Removing illuminate/support (v5.5.28)
  • Removing illuminate/broadcasting (v5.5.28)
  • Removing illuminate/bus (v5.5.28)
  • Removing illuminate/cache (v5.5.28)
  • Removing illuminate/config (v5.5.28)
  • Removing illuminate/console (v5.5.28)

Enum problem still exists

Solution described here does not work anymore for Lumen 5.8.4
eloquent-model-generator version: v1.2.7
error message: Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

SoftDelete trait

Add use of the SoftDelete trait when the deleted_at field is present

Error when I try generate a model

php artisan krlove:generate:model GameRound --table-name=gameRound

[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function getColumns() on null

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGameRoundTable extends Migration
{
    /**
     * Run the migrations.
     * @table gameRound
     *
     * @return void
     */
    public function up()
    {
        Schema::create('gameRound', function (Blueprint $table) {
            $table->integer('idgameRound')->unsigned();
            $table->integer('question_idquestion1')->unsigned();
            $table->integer('question_idquestion2')->unsigned();
            $table->integer('question_idquestion3')->unsigned();
            $table->integer('question_idquestion4')->unsigned();
            $table->dateTime('startDate');
            $table->dateTime('endDate')->nullable();
            $table->integer('user_idUser')->unsigned();
            $table->string('question1Answer', 45)->nullable();
            $table->string('question2Answer', 45)->nullable();
            $table->string('question3Answer', 45)->nullable();
            $table->string('question4Answer', 45)->nullable();
            $table->integer('round');
            $table->integer('game_idgame')->unsigned();
            # Indexes
            $table->index('question_idquestion1');
            $table->index('question_idquestion2');
            $table->index('question_idquestion3');
            $table->index('question_idquestion4');
            $table->index('user_idUser');
            $table->index('game_idgame');


            $table->foreign('question_idquestion1', 'fk_gameRound_question1_idx')
                ->references('idquestion')->on('question')
                ->onDelete('no action')
                ->onUpdate('no action');

            $table->foreign('question_idquestion2', 'fk_gameRound_question2_idx')
                ->references('idquestion')->on('question')
                ->onDelete('no action')
                ->onUpdate('no action');

            $table->foreign('question_idquestion3', 'fk_gameRound_question3_idx')
                ->references('idquestion')->on('question')
                ->onDelete('no action')
                ->onUpdate('no action');

            $table->foreign('question_idquestion4', 'fk_gameRound_question4_idx')
                ->references('idquestion')->on('question')
                ->onDelete('no action')
                ->onUpdate('no action');

            $table->foreign('user_idUser', 'fk_gameRound_user1_idx')
                ->references('idUser')->on('user')
                ->onDelete('no action')
                ->onUpdate('no action');

            $table->foreign('game_idgame', 'fk_gameRound_game1_idx')
                ->references('idgame')->on('game')
                ->onDelete('no action')
                ->onUpdate('no action');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {

        Schema::drop('gameRound');
    }
}

Thanks!

enum type can not generate model

one enum type in my database, if i remove it, then it's work fine, if i add then it can not work.

[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform
may not support it.

cannot generator

I run command but get message There are no commands defined in the "krlove:generate" namespace.

Using Outside of Laravel

I use eloquent capsules on my custom framework and I'm wondering if there is a way that I can use this natively in PHP to generate eloquent models without using the cli?

In ExistenceCheckerProcessor.php line 39: Table user does not exist

I wondering if krlove 1.3 compatible with lumen5.8+posgresql database,
this my .env

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=mydb
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_SCHEMA=public

because ive got that error by calling this line :
php artisan krlove:generate:model User --table-name=user

i decide to uncomment those exception and its works just fine. i just wondering..

GenerateModelCommand:handle() does not exist

Hi,

I am using your package for a pretty long time now, it's really handy to have!

Unfortunately, I recently created a new project in the latest Laravel (5.5) and keep getting an error on the krlove command as you can see below.

Is this due to Laravel 5.5, or am I missing something?

Thank you !

image

Package does't override model defaults config Lumen

I create file name as eloquent_model_generator.php and add this code in file
`
return [
'model_defaults' => [
'namespace' => 'App\Models',
'base_class_name' => \Illuminate\Database\Eloquent\Model::class,
'output_path' => "Models",
'no_timestamps' => null,
'date_format' => null,
'connection' => null,
'backup' => null,
],
];

`
after this config my model must be create in Models folder but it is not. It is created in app directory. What is wrong in this case?

Not working on Laravel 6

Hello,
This is the console log

Using version ^1.3 for krlove/eloquent-model-generator
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove laravel/framework v6.0.1
    - Conclusion: don't install laravel/framework v6.0.1
    - krlove/eloquent-model-generator 1.3.0 requires illuminate/support ^5.0 -> satisfiable by illuminate/support[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-
dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26,
v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.3
4, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25
, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.
2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8
.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.4, v5.8.8, v5.8.9].
    - krlove/eloquent-model-generator 1.3.1 requires illuminate/support ^5.0 -> satisfiable by illuminate/support[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-
dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26,
v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.3
4, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25
, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.
2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8
.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.4, v5.8.8, v5.8.9].
    - krlove/eloquent-model-generator 1.3.2 requires illuminate/support ^5.0 -> satisfiable by illuminate/support[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-
dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26,
v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.3
4, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25
, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.
2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8
.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.4, v5.8.8, v5.8.9].
    - don't install illuminate/support 5.5.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.16|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.17|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.2|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.33|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.34|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.35|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.36|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.37|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.39|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.40|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.41|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.43|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.5.44|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.6.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.1|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.10|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.11|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.12|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.13|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.14|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.15|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.16|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.17|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.19|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.2|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.20|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.21|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.22|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.23|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.24|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.25|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.26|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.27|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.29|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.3|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.30|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.31|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.32|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.33|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.34|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.35|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.36|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.37|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.38|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.39|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.4|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.5|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.6|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.7|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.8|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.6.9|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.7.17|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.7.18|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.7.19|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.7.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.1|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.10|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.11|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.15|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.2|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.20|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.21|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.22|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.23|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.26|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.27|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.3|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.4|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.5|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.6|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.7|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.8|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.7.9|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.8.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.11|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.12|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.14|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.15|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.17|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.18|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.19|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.2|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.20|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.22|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.24|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.27|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.29|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.3|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.30|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.31|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.32|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.33|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.34|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.35|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.4|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.8|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.8.9|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.1.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.2.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.3.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.4.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.1|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.13|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.16|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.2|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.20|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.22|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.25|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.30|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.31|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.41|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.6|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.1.8|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.19|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.21|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.24|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.25|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.26|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.27|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.31|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.32|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.37|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.43|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.45|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.6|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.2.7|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.3.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.3.16|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.3.23|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.3.4|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.13|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.17|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.19|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.27|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.36|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.4.9|don't install laravel/framework v6.0.1
    - don't install illuminate/support 5.0.x-dev|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.0|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.22|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.25|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.26|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.28|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.33|don't install laravel/framework v6.0.1
    - don't install illuminate/support v5.0.4|don't install laravel/framework v6.0.1
    - Installation request for laravel/framework (locked at v6.0.1, required as ^6.0) -> satisfiable by laravel/framework[v6.0.1].
    - Installation request for krlove/eloquent-model-generator ^1.3 -> satisfiable by krlove/eloquent-model-generator[1.3.0, 1.3.1, 1.3.2].


Installation failed, reverting ./composer.json to its original content.

is it possible to run the package for all tables ?

Hi,
I was looking inside the documentation but I couldn't find such thing . is it possible to generate for whole database at once ?
I dont want to add the table one by one
suggestion command

php artisan krlove:generate:all

update model: Fatal error: Call to a member function tablesExist()

Hello,
When I try to update the model with:

php artisan krlove:generate:model NameModel --table-name=name_table

I get this error:

[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function tablesExist() on null

How can I turn it around?
Thank you

db_types option in config file doesn't work

Hello!

Thank you for your package! It is cool thing, but I found little problem.

When I try to use db_types and connection in config eloquent_model_generator then it gives an error.

[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

But if I don't use connection option and change db name in default connection, then it works correct.

I tried different cases use connection in cli args and configs, results are repeated, then it doesn't see db_types array, for example, enum => string.

Best regards,
Ruslan

Overrides local Scopes

Is there a way to check if the model has LocalScopes defined and if so, not overrwrite them?

My table got "um" suffix

Hi,
I have two tables provinsi and kabupatenkota.
The relationship is provinsi has many kabupatenkota

In Provinsi.php model I found that my kabupatenkota table changed its name.
It starts from the class declaration:

* @property Kabupatenkotum[] $kabupatenkotas

and the function of kabupatenkota

/**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function kabupatenkotas()
    {
        return $this->hasMany('App\Kabupatenkotum');
    }

Why my kabupatenkotas model renamed to Kabupatenkotum?

Thank you,

Connection name not used

Hi, thanks for this vendor,
The option --connection seems to not be used in processors however

$this->databaseManager->connection()  //instead of 
$this->databaseManager->connection($someConfigValue)

So only the main database can be directly worked on it

Enum Type Not Supported

[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it

.

RelationProcessor has wrong priority

RelationProcessor depends on work from NamespaceProcessor, but both have priority 5. Due to how usort works and due to the initial order of the Processors, this deterministically works at the first call to EloquentModelBuilder.createModel, but throws at the second.

Can be fixed by increasing RelationProcessor's priority to e.g. 6.

Undefined index: index_type

When i tried to generate model i get index_type error. Can you give me a suggestion how can i solve it?

Error:
[ErrorException] Undefined index: index_type

Also laravel.log ;
[2017-06-09 14:37:46] local.ERROR: ErrorException: Undefined index: index_type in /var/www/html/harcama/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php:75 Stack trace: #0 /var/www/html/harcama/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php(75): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined index...', '/var/www/html/h...', 75, Array) #1 /var/www/html/harcama/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(193): Doctrine\DBAL\Schema\MySqlSchemaManager->_getPortableTableIndexesList(Array, 'parties') #2 /var/www/html/harcama/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(286): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableIndexes('parties') #3 /var/www/html/harcama/vendor/krlove/eloquent-model-generator/src/Processor/FieldProcessor.php(48): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails('parties') #4 /var/www/html/harcama/vendor/krlove/eloquent-model-generator/src/EloquentModelBuilder.php(41): Krlove\EloquentModelGenerator\Processor\FieldProcessor->process(Object(Krlove\EloquentModelGenerator\Model\EloquentModel), Object(Krlove\EloquentModelGenerator\Config)) #5 /var/www/html/harcama/vendor/krlove/eloquent-model-generator/src/Generator.php(35): Krlove\EloquentModelGenerator\EloquentModelBuilder->createModel(Object(Krlove\EloquentModelGenerator\Config)) #6 /var/www/html/harcama/vendor/krlove/eloquent-model-generator/src/Command/GenerateModelCommand.php(53): Krlove\EloquentModelGenerator\Generator->generateModel(Object(Krlove\EloquentModelGenerator\Config)) #7 [internal function]: Krlove\EloquentModelGenerator\Command\GenerateModelCommand->fire() #8 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array) #9 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #10 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #11 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #12 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array) #13 /var/www/html/harcama/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #14 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #15 /var/www/html/harcama/vendor/symfony/console/Application.php(869): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /var/www/html/harcama/vendor/symfony/console/Application.php(223): Symfony\Component\Console\Application->doRunCommand(Object(Krlove\EloquentModelGenerator\Command\GenerateModelCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /var/www/html/harcama/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #18 /var/www/html/harcama/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #19 /var/www/html/harcama/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20 {main}

Error when table does not have Primary Key

I have a table which stores image URLs. This table does not have its own Primary Key (id) but it does have a Foreign Key (id of a different table). the model generator returns this error when the table does not have a PK:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function getColumns() on null

Personally, I think it should be able to handle PKless tables....

Thanks!

Model has been created with a wrong name

Hi,

firstly, congratulations for the contribution, this project is very interesting and it helps a lot.

The issue is: a tried to create a Model from a table called "Conta". However, the file created and the reference for this table was called from "Contum". I don't know if it's a bug.

Thanks in advice.

Tables with enums

Hello!

I have a problem with my DB schema.

I am trying to run: php artisan krlove:generate:model Task
And I get this error:

[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

This is my migration

class CreateTaskTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tasks', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('task_type_id')->unsigned();
            $table->text('observations')->nullable();
            $table->enum('status', ['open', 'closed']);
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::table('tasks', function (Blueprint $table) {
            //TODO: Revisar si las foreigns tienen que ser en cascada.
            $table->foreign('task_type_id')->references('id')->on('taskTypes')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->index(['task_type_id']);
        });


    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('tasks');
    }
}

Thanks for your work!

There are no commands defined in the "krlove:generate" namespace

I follow the instructions until Step 2, that is not clear enough, where to put this line.
My environment (Windows 7 Pro x64):

I've created a test project with

$\composer>composer create-project --prefer-dist laravel/lumen ..\lumen\test
Installing laravel/lumen (v5.6.0)
  - Installing laravel/lumen (v5.6.0): Downloading (100%)
Created project in ..\lumen\test

These are the installed versions I got:

$>composer --version
Composer version 1.7.2 2018-08-16 16:57:12

$>php artisan --version
Laravel Framework Lumen (5.6.4) (Laravel Components 5.6.*)

$>php -version
PHP 7.1.19RC1 (cli) (built: Jun  8 2018 20:11:53) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

(BTW: all in Visual Studio Code Terminal with project 'cd' into project directory. Extensions 'Composer' and 'PHP Extension Pack')

I found the "provider= ["-thingi in 'composer.lock' and 'vendor\composer\installed.json, but without '::class', written from installation, I think.

The file 'GenerateModelComposer.php' (and many more) are available in project directory (.\vendor\krlove\eloquent-model-generator... etc)

My database connection is NOT on localhost, but on a verified extern accessible PostgreSQL 10 (I've successful connections from local development system to this database with pgDbAdmin or DBeaver).
I activate the extension in my php.ini (single php_pdo_pgsql.dll and php_pgsql.dll and both)

But generation fails:

$>php artisan krlove:generate:model Device --table-name=DEVICE

  There are no commands defined in the "krlove:generate" namespace.

I try all variations of the --table-name option: with quotes, without quotes, with schema.table or schema."table", but this seems not to be the problem.

I'm out of ideas, what to do next.

Disable pluralization

Is there any way to run this without pluralizing the table and relationship names?

The database we have has the table names in portuguese so the way it pluralizes the names is kinda weird.

I know it's a Laravel convention to use it that way, but I'd like to generate the classes with the same names as the tables.

Unknown database type enum requested, Doctrine\DBAL\Platforms\MariaDb1027Platform may not support it.

Hello,
I have an enum in my table. So I added the following fix for the migration file. No problem in migration, but when I try to generate model using your library, I get an error.

Here's how I generate the model:

php artisan krlove:generate:model InteriorFeature --table-name=interior_feature

My fix for enum. By the help of this fix, I have no problem with migration:

public function __construct()
    {
        DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.