4 years ago

Best way to save a model with many data

Posted 4 years ago by Giolf

Hi all,

i would like to have some tips and tricks about a smart and good way to save a model in the DB that has many data.
This is the scenario:
I have a form to create a new student, this form has many field (around 30), if the validation doesn't fail in the StudentController i've all the data of the form provided by a Request.

Now in which elegant way could i get this data to put in my model and save it in the DB ? I know exists the method "create" but before to do that i need to "convert" some of the data provided by the request. Where could i execute this type of logic?? maybe in the model? So maybe is an elegant way to add a constructor to my student model and pass to it the request and then run there this type of logic?

what would you do ?

Thank you

Please sign in or create an account to participate in this conversation.