diff --git a/src/PersistentData/Model/Currency.php b/src/PersistentData/Model/Currency.php new file mode 100644 index 0000000..06cbbfd --- /dev/null +++ b/src/PersistentData/Model/Currency.php @@ -0,0 +1,60 @@ + Community::class]; + + private ?Community $community = null; + + private ?int $communityId = null; + + private string $code = ''; + + private int $roundDigits = 0; + + public function setCommunity(Community $community): void + { + $this->community = $community; + } + + public function setCommunityId(int $communityId): void + { + $this->communityId = $communityId; + } + + public function setCode(string $code): void + { + $this->code = $code; + } + + public function setRoundDigits(int $roundDigits): void + { + $this->roundDigits = $roundDigits; + } + + public function getCommunity(): ?Community + { + return $this->community; + } + + public function getCommunityId(): ?int + { + return $this->communityId; + } + + public function getCode(): string + { + return $this->code; + } + + public function getRoundDigits(): int + { + return $this->roundDigits; + } +} diff --git a/src/Repository/CurrencyRepository.php b/src/Repository/CurrencyRepository.php new file mode 100644 index 0000000..b34b089 --- /dev/null +++ b/src/Repository/CurrencyRepository.php @@ -0,0 +1,32 @@ +selectFromDbById($id, Currency::class); + } + + public function getAllByCommunity(Community $community, bool $useRelations = false): Generator + { + $select = new Select(Container::$dbConnection); + $select->where('community_id', '=', $community->getId()); + + yield from Container::$persistentDataManager->selectMultipleFromDb($select, Currency::class, $useRelations); + } + + public function getByCommunityAndCurrencyCode(Community $community, string $code): ?Currency + { + $select = new Select(Container::$dbConnection); + $select->where('community_id', '=', $community->getId()); + $select->where('code', '=', $code); + + return Container::$persistentDataManager->selectFromDb($select, Currency::class); + } +}