How do you handle this generic situation of saving data. Do you have a model and pass a db connection to the model? Or do you have a db repository and then mass the model to the db repo?
I think that's clear. I've done both and I'm curious to see what people think. Would you rather have:
$model = new Model($conn);
or
$dbRepository->save($model)
Pros and cons of either solution? What do you do and why?
Posted Aug 2, 2018, 4:21 PM UTC
The latter. I am a strong believer in not having any sort of logic in DTOs (though honestly so is everyone I know)