I'm asking myself if i'm doing things in the right way. Here is my concern :
I have my User Model like this
class User extends Model {
public function activities()
{
return $this->hasMany('App\Activity');
}
....
public function getTotalDistanceTraveled() {
return Step::join('activities', 'activity_id', '=', 'activities.id')->where('activities.user_id', $this->id)->sum('steps.km');
}
Is it the right place to put function like getTotalDistanceTraveled() in the User Model ? Or it should be in the Controller which generate the View ? Or do I have to create a UserRepository ?
Thanks for your recommandations
Stepin the User model.