Ar Attribute Getter/setter Support

Hi there,

One of my AR models has database properties that need some post-processing when they are set from the outside by non-user input. For example, I want a integer property to be always within a range of -100 to 100. Well, here I ran into an issue.

First I overloaded beforeSave() and did something like $this->example = min(100, max(-100, $this->example)). But I don’t want it to be executed every time the model gets saved, even when that property hasn’t changed at all. So I was looking into creating a setter for this property. However, AR models currently don’t support attribute getters and setters, because the check for attribute existence comes before the check for a setter method in __set().

Why was the decision made to make the AR attribute existence more imporant than a getter/setter method? And is there a chance that it will be implemented in the future, or, how can I fix this problem in my project and future projects?

Thanks, and keep up the good work! :)

set scenarios an change only in that scenario