diff --git a/src/Entity/Member.php b/src/Entity/Member.php index 65108a8..b42bff5 100644 --- a/src/Entity/Member.php +++ b/src/Entity/Member.php @@ -4,7 +4,7 @@ use App\Entity\Membership\MembershipStatus; use Doctrine\ORM\Mapping as ORM; -use Doctrine\Common\Collections\{ ArrayCollection, Collection }; +use Doctrine\Common\Collections\{ArrayCollection, Collection, Criteria, Order}; use Symfony\Component\Validator\Constraints as Assert; use DateTime; use Symfony\Component\Security\Core\User\UserInterface; @@ -255,6 +255,13 @@ public function getPaidContributionPayments(): Collection { return $this->contri public function getContributionPayments(): Collection { return $this->contributionPayments; } + public function getLastContributionPaymentsForListing(): Collection + { + $criteria = Criteria::create() + ->orderBy(["paymentTime" => Order::Descending])->setMaxResults(5); + return $this->contributionPayments->matching($criteria)->filter(fn($payment) => $payment->getStatus() == ContributionPayment::STATUS_PAID); + } + public function isAdmin(): bool { return in_array('ROLE_ADMIN', $this->getRoles()); } public function setIsAdmin(bool $isAdmin): void { if ($isAdmin) diff --git a/templates/user/details.html.twig b/templates/user/details.html.twig index b22fce0..e6d207e 100644 --- a/templates/user/details.html.twig +++ b/templates/user/details.html.twig @@ -140,7 +140,7 @@
- {% for contributionPayment in app.user.paidContributionPayments[:5] %} + {% for contributionPayment in app.user.getLastContributionPaymentsForListing %}