InfyOmLabs / laravel-generator

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

What this really needs is a repeating field and repeating sections #202

Closed phillipmadsen closed 8 years ago

phillipmadsen commented 8 years ago

Do you have any ideas on something like this. This seems to be the bottleneck in development so if we could make it easier it would be very useful to everyone. Example of what I am talking about would be. _SECTIONS EXAMPLE_

USERS > CRUD REPEATING FORM: ROLES or PRODUCTS > CRUD / HasMany REPEATING FORM: PRODUCT_FEATURE_BLOCK / BelongsTo

_FIELDS_

    {
        "fieldInput": "image:string",
        "htmlType": "REPEATING",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false
    },

_OR COMBINED_

  {
        "fieldInput": "section:string",
        "htmlType": "REPEATING",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false
    },
  {
        "fieldInput": "section_id:integer",
        "htmlType": "REPEATING",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false
    },
  {
        "fieldInput": "image:string",
        "htmlType": "REPEATING",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false
    },
  {
        "fieldInput": "content:text",
        "htmlType": "REPEATING",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false
    },

maybe add models to use to make it easier.

  {
        "fieldInput": "feature_id:integer",
        "htmlType": "REPEATING",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false,
        "parentModel":'Product',
        "childModel": 'Feature'
    },

AND A SELECT FIELD GETTING DATA FROM ANOTHER MODEL

  {
        "fieldInput": "roles",
        "htmlType": "MODELSELECT",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false,
        "ModelToUse": 'users',
        "ColumnSelector": 'roles'
    },

something along the lines of the repeating row you have in your generator html.

phillipmadsen commented 8 years ago

Anyway this would make this stand out above the others. Just want to know your thoughts on it.

phillipmadsen commented 8 years ago

you could even add a level up in the fields file that would make all this easier. example

fields-file.json:

[
{
 "model":"Post",
 "relationship": "Post:BelongsTo:Category",
    {
        "fieldInput": "id:increments",
        "htmlType": "",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": false,
        "inIndex": false
    },
    {
        "fieldInput": "content:text",
        "htmlType": "textarea",
        "validations": "required",
        "searchable": true,
        "inForm": true,
        "inIndex": true
    },
    {
        "fieldInput": "category:string",
        "htmlType": "MODELSELECT",
        "searchable": true,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": false,
        "ModelToUse": 'Category',
        "ColumnSelector": 'title'
    },
    {
        "fieldInput": "post_date:dateTime",
        "htmlType": "date"
    },
 },{
 "model":"Category",
 "relationship": "Category:HasMany:Post"
    {
        "fieldInput": "id:increments",
        "htmlType": "",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": false,
        "inIndex": false
    },
  {
        "fieldInput": "title:string",
        "htmlType": "text",
        "searchable": true,
        "fillable": true,
        "primary": index,
        "inForm": true,
        "inIndex": true
    },
    {
        "fieldInput": "content:text",
        "htmlType": "textarea",
        "validations": "required",
        "searchable": true,
        "inForm": true,
        "inIndex": true
    }, 
 }

]
phillipmadsen commented 8 years ago

Maybe a command to generate the fields-file.json framework would be greate also.

php artisan infyom:fields-file Post or php artisan infyom:fields-file:parent-child Category SubCategory

generates category-subcategory.json - skeleton

    [
    {
    "model":"Post",
    "relationship": "Category:HasMany:SubCategory",
        {
        "fieldInput": "id:increments",
        "htmlType": "",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": false,
        "inIndex": false
        },
    },{
    "model":"Category",
    "relationship": "SubCategory:BelongsTo:Category"
        {
        "fieldInput": "id:increments",
        "htmlType": "",
        "validations": "",
        "searchable": false,
        "fillable": false,
        "primary": true,
        "inForm": false,
        "inIndex": false
        },
        {
        "fieldInput": "category_id:integer:unsigned",
        "htmlType": "foreign:index",
        "validations": "",
        "searchable": false,
        "fillable": true,
        "primary": false,
        "inForm": false,
        "inIndex": false
        }
    }
    ]
mitulgolakiya commented 8 years ago

@phillipmadsen This can be a part of foreign key & relationships.

mitulgolakiya commented 8 years ago

duplicate of https://github.com/InfyOmLabs/laravel-generator/issues/51