What would be the best practice, within the MVC standard, to handle the data? [closed]

4

An example (I usually use CakePHP, but the question would be for any framework and language): for saving date type fields in the database I have to convert a field from the format dd/mm/yyyy to yyyy-mm-dd . For this, I use a simple function called converteData(data) that is inside the AppController (parent class of all CakePHP controls). So, the conversion looks like this:

$this->request->data['Cliente']['vinculoDataInicio'] = $this->converteData($this->request->data['Cliente']['vinculoDataInicio']);

I usually do this inside the controls. So the data is passed in the right format for the template, which will still validate them before saving them.

My question is: is this ideal or should I simply pass all the data to the model so that it can handle, validate and save the data?

    
asked by anonymous 23.08.2016 / 22:35

0 answers