Add new option for make:model for specific table - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: Add new option for make:model for specific table (/showthread.php?tid=88137) |
Add new option for make:model for specific table - datamweb - 07-27-2023 Usually, after building the model, I have to add the names of the fields to $allowedFields.This is time-consuming for me. I don't know exactly whether other developers have experienced this issue or not. I suggest to add a new option to command php spark make:modelfor this issue. Option -for takes the name of the table and adds the fields to $allowedFields to generate the model. I think this option helps a lot in saving the developer's time. Code: Data of Table "sms_sender": Code: php spark make:model -for sms_sender PHP Code: protected $DBGroup = 'default'; RE: Add new option for make:model for specific table - iRedds - 07-27-2023 I like this idea. RE: Add new option for make:model for specific table - kenjis - 07-27-2023 No problem. Good idea! RE: Add new option for make:model for specific table - ozornick - 07-27-2023 I agree. I myself had tables of the type date_1, date_N... When creating, it is important to take into account the primary key RE: Add new option for make:model for specific table - InsiteFX - 07-27-2023 Yes, good idea but somefields will not need to be in allowFields. So we will need to look into that. RE: Add new option for make:model for specific table - luckmoshy - 07-27-2023 i agree too @datamweb RE: Add new option for make:model for specific table - ozornick - 07-28-2023 (07-27-2023, 10:35 PM)InsiteFX Wrote: Yes, good idea but somefields will not need to be in allowFields.For example? Default dates can be added (created_at, etc). ID as the `id` field to ignore. There is a problem if the ID is of a different type (`product_id`). Then you need to request it from the console. After creating the model, remind the developer to check these fields RE: Add new option for make:model for specific table - iRedds - 07-28-2023 ID and timestamps are not needed in $allowedFields. RE: Add new option for make:model for specific table - FabriceL - 07-31-2023 I also agree that it's a good idea. RE: Add new option for make:model for specific table - kenjis - 10-31-2023 The option --table was implemented. Code: $ php spark make:model --help |