You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the comment for this attribute is a bit misleading. Specifying attributes in this array will definitely make them immutable. Even updating a model via own code will throw the Exception, at least when doing a ->save(). Not sure if you meant that attributes in the array can be modified by code (like, they're not constants), but they can't be written to database.
In my mind I already replied to this, but apparently not haha. So the idea of immutable is very much the same as fillable and guarded for example - it's not supposed to stop the developer from actually doing it internally (nor do I support that), it's only to stop it from happeing "automagically" by the boilerplate.
Simple use case, let's say you have a user registration, and they put in their birth date. Totally normal, and you will want that fillable. However, someone's birthday doesn't generally ever change, so you don't want them to actually update it, to prevent user abuse/getting around restrictions. So you specify to make it immutable, and the boilerplate will not allow updating it through normal patch/put.
However if you override all that logic and/or are doing something manually somewhere, sure you will need to consider your own business case - much like how laravel's fillable works (allabit slightly differently).
I will actually update the code comment and docs to make it more clear. I might rework the implementation a bit as well, as I think maybe it could be improved. For example, now it should actually prevent you from saving those changes, but it might not work in some circumstances, where the model was serialised for example.
Hello again!
I think the comment for this attribute is a bit misleading. Specifying attributes in this array will definitely make them immutable. Even updating a model via own code will throw the Exception, at least when doing a ->save(). Not sure if you meant that attributes in the array can be modified by code (like, they're not constants), but they can't be written to database.
l5-api/src/Models/RestfulModel.php
Line 33 in 2212551
The text was updated successfully, but these errors were encountered: