I'm creating a CRON in my Symfony 4 App (command) to archive news that is older than 60 days. How should this be done?
My first instinct was to add a method to my NewsRepository
to retrieve all news that needs to be archive and update their isArchived
boolean method from false to true if it's the case.
Then, I had this idea of adding the logic for archiving the news inside the repository so that it's usable outside the Command. I could also put the logic (MySQL Updates) inside the Command and just have the ''find'' query inside the repository.
Which of these approaches is preferable, and why? Should my repository method be findNewsToArchive
and do the update logic inside the command, or should it be archiveAllNewsThatNeedsToBeArchived
and do all the logic in the repository?