Auto update protected allowed fields in Codeigniter 4

Viewed 185

Using Ci4/MYSQL I have created a table (Table C), whose rows (Table A) and columns (Table B) are automatically generated from the inputs into two other tables.

Table A contains details of properties Table B contains details of repairs Table C shows what repairs have been done to each property

The issue that I'm having is that is in order to update Table C in model I need to specify the protected allowed fields. But as the columns are being generated from the rows of another table I would have to manually type each allowed field.

Is there a way I could update/disable the allowed fields to remove the manual input?

1 Answers

Occasionally, you will find times where you need to disable the protected features of a table. In these cases, you can turn the protection on or off:

$model->protect(false)
      ->insert($data)
      ->protect(true);
Related