It depends. If it is a small query and is used for one page or for one api endpoint, then you should put it in controller. if it's a more complex query, then make custom class as a Service for the querry. If it has to be a query that takes care of relationships or it is fundamental for the model, then put it into the model.