$score = 0; foreach $vote ($item->votes()) { $score += $vote->value() * weight($item->age() - $vote->age()); }