Answer the question
In order to leave comments, you need to log in
Is there a method on the model that is called when the model is loaded?
I need to increment the number of views when the data in the model is loaded.
Answer the question
In order to leave comments, you need to log in
To increment something, there is a ->increment('field') method.
If you do it when the model is loaded, how many views you will have, simply because somewhere the selection is made for various internal needs.
At the same time, there is no protection against cheating, etc.
The views increment should be added exactly where the result is displayed and seasoned with checks for the fact that the person / ip address has already looked and all that, if necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question