diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-15 13:43:05 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-15 13:43:05 +0100 |
commit | 254eb4a9959e4c281fdeb47378a654de978cb1e4 (patch) | |
tree | c2c4bb19e2c16cddc82988f50de79c718f381b22 /src/Model/Village.php | |
parent | 09caff2b2a06d1f8ac8203567035a21c612165f9 (diff) |
events and satisfaction
Diffstat (limited to 'src/Model/Village.php')
-rw-r--r-- | src/Model/Village.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Model/Village.php b/src/Model/Village.php index 03a57b7..ff0b7e8 100644 --- a/src/Model/Village.php +++ b/src/Model/Village.php @@ -143,6 +143,17 @@ class Village return $results[0] ?? null; } + public static function getPopulationDemand(int $villageId): int + { + return array_reduce( + Village::getUnits($villageId, Village::FETCH_UNIT_RESIDENCE, Village::RETURN_UNIT_EXISTING), + function ($carry, Unit $unit) { + return $carry + $unit->getPopulationDemand(); + }, + 0 + ); + } + public const FETCH_UNIT_HOME_AT_HOME = 1; public const FETCH_UNIT_HOME_AT_SUPPORT = 2; public const FETCH_UNIT_SUPPORT_AT_HOME = 3; |