Pregunta

just a quick question. I'm developping in cakePHP

I'd like to add a reference number to every entry in my Model, and for that i'd like a function, that will be executed in the Model's beforeSave() that will count the number of entries already created this month, and my ref number will then be YYYMMXXX, with XXX the number of this entry since day one of the month.

Should i place this counting function in the Controller or the Model ? I have a doubt here..

Thanks for the advice !

¿Fue útil?

Solución

It will be better to place the functon in your model because logical part of coding is done in the model.Also it will provide reusability of code.Since controller is not used for writing logic you can use model for that.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top