RVRNEXT-22 use Select::paginate in repositories

This commit is contained in:
Bence Pőcze 2023-05-28 20:33:20 +02:00
parent bf415a2a46
commit 9929e00a3f
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D
2 changed files with 6 additions and 6 deletions

View File

@ -52,11 +52,11 @@ class EventRepository
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations); yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations);
} }
public function getPagedByCommunity(Community $community, int $start, int $limit, bool $useRelations = false, array $withRelations = []): Generator public function getPagedByCommunity(Community $community, int $page, int $itemsPerPage, bool $useRelations = false, array $withRelations = []): Generator
{ {
$select = $this->selectAllByCommunity($community); $select = $this->selectAllByCommunity($community);
$select->orderBy('start', 'DESC'); $select->orderBy('start', 'DESC');
$select->limit($limit, $start); $select->paginate($page, $itemsPerPage);
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations); yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations);
} }

View File

@ -66,20 +66,20 @@ class TransactionRepository
return $select->count() > 0; return $select->count() > 0;
} }
public function getPagedByCommunity(Community $community, int $start, int $limit, bool $useRelations = false, array $withRelations = []): Generator public function getPagedByCommunity(Community $community, int $page, int $itemsPerPage, bool $useRelations = false, array $withRelations = []): Generator
{ {
$select = $this->selectAllByCommunity($community); $select = $this->selectAllByCommunity($community);
$select->orderBy('time', 'DESC'); $select->orderBy('time', 'DESC');
$select->limit($limit, $start); $select->paginate($page, $itemsPerPage);
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Transaction::class, $useRelations, $withRelations); yield from Container::$persistentDataManager->selectMultipleFromDb($select, Transaction::class, $useRelations, $withRelations);
} }
public function getPagedByEvent(Event $event, int $start, int $limit, bool $useRelations = false, array $withRelations = []): Generator public function getPagedByEvent(Event $event, int $page, int $itemsPerPage, bool $useRelations = false, array $withRelations = []): Generator
{ {
$select = $this->selectAllByEvent($event); $select = $this->selectAllByEvent($event);
$select->orderBy('time', 'DESC'); $select->orderBy('time', 'DESC');
$select->limit($limit, $start); $select->paginate($page, $itemsPerPage);
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Transaction::class, $useRelations, $withRelations); yield from Container::$persistentDataManager->selectMultipleFromDb($select, Transaction::class, $useRelations, $withRelations);
} }