Iam kinda getting hard to formulate when a model is needed. Is it like each table should have its own model?
The principal is so easy, let's say you have a login page, in ideal MVC framework, you would have a model called e.g. LoginModel this model would have login method which would contain all the logic of what will happen if the user is trying to login from validations to authentication and security checks. now you have a controller called LoginController, this controller would get called when the user is on domain.tld/login It would render the views accordingly and call the logic in the models, Like: // if user is logged in redirect to main-page, if not show the view if (LoginModel::isUserLoggedIn()) { Redirect::home(); } else { $data = array('redirect' => Request::get('redirect') ? Request::get('redirect') : NULL); $this->View->render('login/index', $data); } Pls note that in ideal properly implemented MVC controller MUST NOT contain logic
Обсуждают сегодня