InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 812 forks source link

having to manually put $table->timestamps(); #692

Closed timoteo7 closed 5 years ago

timoteo7 commented 5 years ago

in config/infyom/laravel_generator.php

'timestamps' => [
    'enabled'       => true,
    'created_at'    => 'created_at',
    'updated_at'    => 'updated_at',
    'deleted_at'    => 'deleted_at',
],

i do: php artisan infyom:migration example --fieldsFile="resources/js/example.json"

the result in my migration is:

$table->increments('id');
$table->string('name', 190);
$table->smallint('example1')->unsigned()->nullable();
$table->decimal('example2', 10, 2)->unsigned()->nullable();
$table->softDeletes();

i'm having to manually put $table->timestamps();

i did something wrong not to go automatically?

mitulgolakiya commented 5 years ago

@timoteo7 Can you paste your resources/js/example.json here? Also, specify which version of laravel and generator you are using?

timoteo7 commented 5 years ago

Laravel is 5.8 "infyomlabs/laravel-generator": "5.8.x-dev", "infyomlabs/swagger-generator": "dev-master",

[ { "name": "id", "htmlType": "", "dbType": "increments", "validations": "", "searchable": false, "fillable": false, "primary": true, "inForm": false, "inIndex": false }, { "name": "titulo", "htmlType": "text", "dbType": "string,190", "validations": "required" }, { "name": "periodo", "htmlType": "number", "dbType": "smallint:unsigned:nullable" }, { "name": "bonus", "htmlType": "number", "dbType": "decimal,10,2:unsigned:nullable" } ]

mitulgolakiya commented 5 years ago

@timoteo7 when you are generating crud from files, it needs to have timestamps fields. But if are using CLI then timestamps are not needed, but when we save a file, we store timestamp fields there. so add timestamps fields in your JSON file and it should work.

{
    "name": "created_at",
    "dbType": "timestamp",
    "htmlType": null,
    "validations": null,
    "searchable": false,
    "fillable": false,
    "primary": false,
    "inForm": false,
    "inIndex": false
},
{
    "name": "updated_at",
    "dbType": "timestamp",
    "htmlType": null,
    "validations": null,
    "searchable": false,
    "fillable": false,
    "primary": false,
    "inForm": false,
    "inIndex": false
}