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

bug in php artisan resource-file:from-database, wrong json field data type validation

Open larg000 opened this issue 1 year ago • 0 comments

Environment:

  • Laravel-Code-Generator Version: 2.4.9
  • Laravel Version: 10

Description:

bug in ressource generator command php artisan resource-file:from-database

dont convert correctly some field in ressource .json file

after many test, seems can't have a string field with the word 'age' inside like image otherwise it is convert from string to numeric

CREATE TABLE IF NOT EXISTS test ( id int(10) unsigned NOT NULL AUTO_INCREMENT, image varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (id)

Steps/Commands To Reproduce:

php artisan resource-file:from-database Test

Content Of The Resource-File:

{
            "name": "image",
             ...
            "html-value": null,
            "validation": "nullable|numeric", // instead of "nullable|string|min:0|max:255"
            ...
}

modify image to imaga or imago php artisan resource-file:from-database Test it works

{
            "name": "imago",
             ...
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "nullable|string|min:0|max:255",
            ...
}

larg000 avatar Mar 12 '23 01:03 larg000