laravel-generator icon indicating copy to clipboard operation
laravel-generator copied to clipboard

[Feature]: need to adjust generate from table output

Open madsynn opened this issue 8 years ago • 3 comments

The first item generated is the id:increments and its being generated like "fieldInput": "id:integer,true,true", and reverse these two. "inForm": true, "inIndex": false

    {
        "fieldInput": "id:increments",
        //** "fieldInput": "id:increments:guarded ",   //** possible
        "htmlType": "number",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": false,
        "inIndex": true
    },

just thinking outside the box but maybe we can add a protected / guarded option for the fields and a protected option to the dates. to output into the model or i guess just add it regardless to all models.

Model.php

protected $guarded = ['id'];
protected $dates = ['published_at', 'deleted_at'];

Also on the date fields you should change to false by default.

{
        "fieldInput": "created_at:dateTime",
        "htmlType": "date",
        "validations": "",
        "searchable": true,
        "fillable": false,
        "primary": false,
        "inForm": false,
        "inIndex": false
    },

madsynn avatar Sep 20 '16 18:09 madsynn

I also noticed in your sample file you have it formatting the fields like this:

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

but in the actual output from table they are formatted like this:

  {
        "fieldInput": "id:integer,true,true",
        "htmlType": "number",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": true,
        "inIndex": false
    },

What is this are is it now part of the generator?

 "dbType": "",
 "type": "",
 "relation": ""

if they are now part of it i would format the main sample file to copy the new format accordingly weather they are used on everyfield or not. Its getting a bit confusing. Also in relation fields we should add 2 more options for update and delete "cascade"

  {
        "fieldInput": "id:guarded",
        "dbType": "increments",
        "htmlType": "number",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": true,
        "inIndex": false,
        "type": "relation",
        "relation": "1tm,Feature",
        "update": "cascade",
        "delete": "cascade"
    },

madsynn avatar Sep 20 '16 19:09 madsynn

@madsynn it's already there, also dbType is supported and you can specify it. image

relationship you can define like dbType": "integer:unsigned:foreign,users,id

ShaileshInfyom avatar Jan 28 '22 09:01 ShaileshInfyom

@madsynn at the moment we don't have any support related to guarded but we will keep in our queue.

ShaileshInfyom avatar Jan 28 '22 10:01 ShaileshInfyom