Question
What are the Best Practices on where place the ORM's implementation in a MVC like software application?
I'm using Laravel, with Eloquent, the default ORM.
The documentation alludes to the fact that ORM calls are fine in the Controller, but that doesn't sit right.
For example, let's say I want to get a User. User::findOrFail($id)
is the code I need. The documentation has this inside the Controller (Latest version V.10 Basic Controllers.
Imagine I have this bit of code in 100 places throughout the project and I need to hang another check off it, perhaps to get the user who also has a flag against their account. This is a bit of a hassle, but were it in the model I would simply update the model method.
An example model method in this instance:
function get_user_by_id($id)
{
return User::findOrFail($id);
}
The downside to this is that the models will soon become huge.
So, what is the best-practice here?