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

The problem with the model, whose name is "Goods" #853

Closed noxeone closed 4 years ago

noxeone commented 4 years ago

When the model name ends in "S", sometimes there may be problems: In the file ViewServiceProvider.php created a line use App\Models\Good; Without "S"! And in the same file the model call looks like: $goodItems = Good::pluck('name','goods_id')->toArray(); Good without "S".

mitulgolakiya commented 4 years ago

@noxeone can you let me know what command you are running and what model name and fields you are giving?

noxeone commented 4 years ago

Thanks for the answer!

Model Goods was created from schema file, with command:

php artisan infyom:api_scaffold Goods --fieldsFile=JSON/Goods.json

These lines appear in the file ViewServiceProvider.php after creation relation with another database table from schema file SaleGoods.json:

{ "name": "goods_id", "dbType": "integer:unsigned:foreign,goods,goods_id", "htmlType": "selectTable:goods:name,goods_id", "relation": "mt1,goods,goods_id,goods_id", "validations": "", "searchable": false, "fillable": true, "primary": false, "inForm": true, "inIndex": true, "inView": true },

noxeone commented 4 years ago

In a neighboring Issue, I answered in more detail: https://github.com/InfyOmLabs/laravel-generator/issues/851

ajayinfyom commented 4 years ago

@noxeone you can pass model name in htmlType.

like this: "htmlType": "selectTable:goods,Goods:name,goods_id",