Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Model binding for protected internal set properties

In my model classes I have multiple properties that are 'protected internal set'. Once these properties are created they should not be able to be modified. Having said that I am having a hard time creating a model binder that will allow these properties to be set upon creation. What is the best way to proceed in order to be able to set these properties just once?

like image 760
mmekaiel Avatar asked Jul 08 '26 18:07

mmekaiel


1 Answers

Unfortunately, this is not something you can do automatically. You'll have to create a unique model binder for each type, and then create the objects using constructor parameters.

like image 171
Erik Funkenbusch Avatar answered Jul 10 '26 17:07

Erik Funkenbusch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!