Think of controllers as just one of the entry points for your application, so they should have as little code as possible. I say this because there may be other input points such as commands, Apis etc.
In general most of the code in my applications lies in the models (which, for me, are representations of the entities of the application, which in turn are replicated in the database); in the repositories (responsible for bringing an instance or a collection of entities); and in services (which are responsible for performing a specific task in the application).
Returning to your question, you say you want to search for news in the spotlight. I would do it this way:
- Have a method in the controller mapped to the route (for example)
/noticias/destaques
. The method could be called NoticiasController::destaquesAction
.
- Have an entity
Noticia
, that represents the news in your database, and a class NoticiasRepository
, responsible for bringing news or a collection of them.
- Have a method
NoticiasRepository::getNoticiasEmDestaque
that returns a collection of featured news, ordered to your liking.
- Finally, call this method from your controller and render it in the view.
This is how I usually develop my applications. If you have any opinion about it, just say the word. :)
On the model, think of it as a bridge between you and the comic.
– bfavaretto