I've been building a system with MVC pattern, and im stuck with the implementation of methods.
In my application, a company can get rating by the users. The company can or not exists in my application, so before the insert the rating the company have to exists in database.
My question is: have i to implement all the business logic in model or some validations in controller?
CONTROLLER
$_POST
;insert()
from Company model and return the inserted id;$_company_id
(Rating model);CONTROLLER
$_POST
insert()
from Rating model with company parametersRATING MODEL
insert()
from Company model and return the inserted id;$_company_id
(Rating model);What MVC means and what we have learned so far.
M(Model) -> Used to perform database operations.
V(Views) -> viewing the data in browser.
C(Controller) -> handle model and view.
So i would say, in your case, go ahead with 2nd option.
If you have any validations to be done, do it in controller.