feat: display teamers' average ratings in several locations
This commit is contained in:
@@ -496,6 +496,23 @@ class Teamer implements TimestampableEntityInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAverageRating(): ?int
|
||||
{
|
||||
$feedbackCount = $this->getFeedback()->count();
|
||||
|
||||
if (0 === $feedbackCount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sum = 0;
|
||||
|
||||
foreach ($this->getFeedback() as $feedback) {
|
||||
$sum += $feedback->getAverageRating();
|
||||
}
|
||||
|
||||
return $sum / $feedbackCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, TrainingAttendance>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user