When is it best to write a Doctrine query and when is it best to write methods for the object? This is what I perceive, but I'd like to get a more experienced opinion. I am trying to abide by good practice whenever possible.
Pros:
Cons:
Pros:
Cons:
I sometimes wonder the same thing, however given your example I would add a method to your teachers custom repository. This way there is no cons, and it is also reusable
In other cases to help me decide I generally look at how many objects there potentially could be and how many sql statements doctrine is going to execute to do my lookup, if it is going to be a lot I will usually use DQL