I am a newbie. I encountered a problem when practicing code. When doing multi-form submission data verification, should I put the verification in the controller layer or the model layer? This verification includes judging whether the field is Empty, but also to determine the uniqueness of a certain field, etc. I checked it myself, and some answers are to put the verification on the controller layer, but the TP manual has automatic verification, which is placed on the model layer, so I am a bit confused. I hope you can give me some advice.
I am a newbie. I encountered a problem when practicing code. When doing multi-form submission data verification, should I put the verification in the controller layer or the model layer? This verification includes judging whether the field is Empty, but also to determine the uniqueness of a certain field, etc. I checked it myself, and some answers are to put the verification on the controller layer, but the TP manual has automatic verification, which is placed on the model layer, so I am a bit confused. I hope you can give me some advice.
Give you a manual link, I hope it can help you automatically verify
Place it in the Model layer, so that before automatically creating data $this->create(), you can verify the data according to the validate defined in the Model. Personally, I think encapsulation would be better. This is called dynamic validate
The project I am writing is placed in the controller.