From d1c926541aec0f8035e29b7bdefe9010ecf0247d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 28 May 2023 20:33:44 +0200 Subject: [PATCH] RVRNEXT-22 use the new repository methods in controllers --- src/Controller/EventController.php | 7 +++---- src/Controller/TransactionController.php | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Controller/EventController.php b/src/Controller/EventController.php index be72ca1..ab2aa5f 100644 --- a/src/Controller/EventController.php +++ b/src/Controller/EventController.php @@ -68,17 +68,16 @@ class EventController implements IAuthenticationRequired, ISecured { $itemsPerPage = 10; $numberOfEvents = $this->eventRepository->countAllByCommunity($this->community); - $pages = ceil($numberOfEvents / $itemsPerPage); - $currentPage = Container::$request->query('page') ?: 0; + $currentPage = Container::$request->query('page') ?: 1; $events = $this->eventRepository->getPagedByCommunity( $this->community, - $currentPage * $itemsPerPage, + $currentPage, $itemsPerPage ); return new HtmlContent('events/events', [ 'community' => $this->community, - 'pages' => $pages, + 'pages' => ceil($numberOfEvents / $itemsPerPage), 'currentPage' => $currentPage, 'numberOfEvents' => $numberOfEvents, 'events' => $events diff --git a/src/Controller/TransactionController.php b/src/Controller/TransactionController.php index 2a08ff5..0bbb91c 100644 --- a/src/Controller/TransactionController.php +++ b/src/Controller/TransactionController.php @@ -84,19 +84,18 @@ class TransactionController implements IAuthenticationRequired, ISecured $numberOfTransactions = $event ? $this->transactionRepository->countAllByEvent($event) : $this->transactionRepository->countAllByCommunity($this->community); - $pages = ceil($numberOfTransactions / $itemsPerPage); - $currentPage = Container::$request->query('page') ?: 0; + $currentPage = Container::$request->query('page') ?: 1; $transactions = $event ? $this->transactionRepository->getPagedByEvent( $event, - $currentPage * $itemsPerPage, + $currentPage, $itemsPerPage, true, ['currency', 'payer_user', 'payee_user'] ) : $this->transactionRepository->getPagedByCommunity( $this->community, - $currentPage * $itemsPerPage, + $currentPage, $itemsPerPage, true, ['event', 'currency', 'payer_user', 'payee_user'] @@ -106,7 +105,7 @@ class TransactionController implements IAuthenticationRequired, ISecured 'community' => $this->community, 'event' => $event, 'exchangeRateCalculator' => $exchangeRateCalculator, - 'pages' => $pages, + 'pages' => ceil($numberOfTransactions / $itemsPerPage), 'currentPage' => $currentPage, 'numberOfTransactions' => $numberOfTransactions, 'transactions' => $transactions