RVRNEXT-43 extend community member repository with count
This commit is contained in:
parent
eebf4aff00
commit
4e9c7f8c3c
@ -15,12 +15,16 @@ class CommunityMemberRepository
|
||||
|
||||
public function getAllByCommunity(Community $community, bool $useRelations = false, array $withRelations = []): Generator
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('community_id', '=', $community->getId());
|
||||
$select = $this->selectAllByCommunity($community);
|
||||
|
||||
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, CommunityMember::class, $useRelations, $withRelations);
|
||||
}
|
||||
|
||||
public function countAllByCommunity(Community $community): int
|
||||
{
|
||||
return $this->selectAllByCommunity($community)->count();
|
||||
}
|
||||
|
||||
public function getAllByUser(User $user, bool $useRelations = false, array $withRelations = []): Generator
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
@ -37,4 +41,11 @@ class CommunityMemberRepository
|
||||
|
||||
return \Container::$persistentDataManager->selectFromDb($select, CommunityMember::class);
|
||||
}
|
||||
|
||||
private function selectAllByCommunity(Community $community): Select
|
||||
{
|
||||
$select = new Select(\Container::$dbConnection, CommunityMember::getTable());
|
||||
$select->where('community_id', '=', $community->getId());
|
||||
return $select;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user