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

Options cannot be generated with key value pairs

Open mushtaqj opened this issue 7 years ago • 2 comments

Environment:

  • Laravel-Code-Generator Version: 2.2
  • Laravel Version: 5.6

Description:

Cannot specify options for select with key value pairs in the command line

image

Steps/Commands To Reproduce:

php artisan resource-file:create AuditFacility --fields="id,name:name;validation:required,name:address;validation:required,contact_id,contact_designation,longitude,latitude,audit_division_id,distance_from_hac, name:in_house;data-type:boolean,name:facility_type;data-type:enum;html-type:select;options:1:Plant|2:Storage|3:Cold Room,created_by,modified_by"

Content Of The Resource-File:

{
    "fields": [
        {
            "name": "id",
            "labels": "Id",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": false,
            "is-on-show": false,
            "is-on-form": false,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": true,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": true,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter id here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "name",
            "labels": "Name",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|string|min:1|max:255",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [
                255
            ],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": true,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter name here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "address",
            "labels": "Address",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "required|string|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": false,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter address here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "contact_id",
            "labels": "Contact",
            "html-type": "select",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": true,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Select contact",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": {
                "name": "contact",
                "type": "belongsTo",
                "params": [
                    "App\\Models\\Contact",
                    "contact_id"
                ],
                "field": "name"
            },
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "contact_designation",
            "labels": "Contact Designation",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "string|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter contact designation here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "longitude",
            "labels": "Longitude",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "string|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter longitude here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "latitude",
            "labels": "Latitude",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "string|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter latitude here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "audit_division_id",
            "labels": "Audit Division",
            "html-type": "select",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": true,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Select audit division",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": {
                "name": "auditDivision",
                "type": "belongsTo",
                "params": [
                    "App\\Models\\AuditDivision",
                    "audit_division_id"
                ],
                "field": "name"
            },
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "distance_from_hac",
            "labels": "Distance From Hac",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "string|min:1",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "string",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter distance from hac here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "in_house",
            "labels": "In House",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "boolean",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "bool",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Enter in house here...",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "facility_type",
            "labels": "Facility Type",
            "html-type": "select",
            "css-class": "",
            "options": {
                "1": "1"
            },
            "html-value": null,
            "validation": "",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "enum",
            "data-type-params": [],
            "data-value": null,
            "is-index": false,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": false,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Select facility type",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": null,
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null
        },
        {
            "name": "created_by",
            "labels": "Created By",
            "html-type": "select",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": false,
            "is-on-show": true,
            "is-on-form": false,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": true,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Select created by",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": {
                "name": "creator",
                "type": "belongsTo",
                "params": [
                    "App\\User",
                    "created_by"
                ],
                "field": "name"
            },
            "foreign-constraint": null,
            "on-store": "Illuminate\\Support\\Facades\\Auth::Id();",
            "on-update": null
        },
        {
            "name": "modified_by",
            "labels": "Modified By",
            "html-type": "select",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": false,
            "is-on-show": true,
            "is-on-form": false,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": true,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Select modified by",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": {
                "name": "updater",
                "type": "belongsTo",
                "params": [
                    "App\\User",
                    "updated_by"
                ],
                "field": "name"
            },
            "foreign-constraint": null,
            "on-store": null,
            "on-update": "Illuminate\\Support\\Facades\\Auth::Id();"
        }
    ],
    "relations": [],
    "indexes": [],
    "auto-manage-created-and-updated-at": true,
    "table-name": null,
    "protection": {
        "is-model-protected": false,
        "is-controller-protected": false,
        "is-form-request-protected": false,
        "is-languages-protected": false,
        "is-form-view-protected": false,
        "is-index-view-protected": false,
        "is-create-view-protected": false,
        "is-edit-view-protected": false,
        "is-show-view-protected": false
    }
}

mushtaqj avatar Mar 17 '18 11:03 mushtaqj

There is no support for this option as of now. We'll add it on future releases.

MikeAlhayek avatar Mar 20 '18 04:03 MikeAlhayek

"data-type-params": [], has a problem to...

When a create a resource file like this:

php artisan resource-file:create Order --fields="id,name:clients_id;data-type:integer,order;name:discount;data-type:double;data-type-params:5,2,name:is_active;data-type:integer"

Is not working... if you look data-type-params:5,2 like the documentation, the "comma" is conflictive .... now i try:

data-type-params:[5,2] data-type-params:"5,2" data-type-params:'5,2'

All ways, is not woking, i mind, the json result is the same "data-type-params": []

mgip avatar Aug 08 '22 11:08 mgip