oop - What exactly is the model in MVC -


I'm a bit confused about the model is quite limited. I think it works with data from the database and so on. Can it be used for something else? Take for example a certification system that sends an activation email to a user when they register. Where is the most appropriate place to place the code for the email? Is a model suitable ... or can it be kept in better view, controller, etc.?

The model is how you represent the data of the application. This is the state of the application, the data that will affect the editing of the application (view: visual presentation), and the variables that can be tweaked by the controller.

To answer your question specifically

The content of the email, the person sending the email, is the model.

This code that sends email (and verifies email / registration verifies first place) and email content is set in the controller. The administrator can also generate email content - you probably have an email template in the model, and the controller can replace the placeholder with the correct values ​​from its processing.

Basically the "Authentication email has been sent to your account" or "Your email address is not valid" so the controller looks at the model and determines the output for the view.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -