I have a DB table with columns. This table has a model for it.
Now, a certain column, I want that when I reference it, say with:
[size="2"]I want to do something with the attribute before its returned to the client who run this line of code.[/size]
[size=“2”]Now, since certain_attr is an attribute that has a column for it, I cannot create a ‘getter’ method that will be called, as done with virtual attributes. As detailed in this wiki article (see 'resolving conflicts" section), the check [/size]whether its a column for that model will be made first, and the value returned as is.
My solution as of now is to overwrite __get() in the certain model to change the exact precedence in which the value is checked.
EDIT: actually, what I change is that in this overwriting __get(), I first call the parent __get() but then searches for a ‘getter’ method and if it exists, I call it on the value returned from the parent __get().
Have overlooked a better solution?