GET /billing/claims loaded every tenant claim with no limit. Add
findByTenant(page, limit) + countByTenant (shared query builder), default
limit 50 / max 100, and expose totals as data.meta — kept inside the existing
{ data: { data: [...] } } envelope so current clients are unaffected.
GET /wallet/transactions was already bounded (findByUser defaulted to limit 50)
but page-less; add page/offset + countByUser + the same additive meta.
Regression: tests/Billing/ClaimsListPaginationTest,
tests/Settlement/WalletTransactionsPaginationTest.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
974 B
PHP
34 lines
974 B
PHP
<?php
|
|
|
|
namespace App\Settlement\Repository;
|
|
|
|
use App\Auth\Entity\User;
|
|
use App\Settlement\Entity\WalletTransaction;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class WalletTransactionRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, WalletTransaction::class);
|
|
}
|
|
|
|
/** @return WalletTransaction[] */
|
|
public function findByUser(User $user, int $limit = 50, int $offset = 0): array
|
|
{
|
|
return $this->findBy(['user' => $user], ['createdAt' => 'DESC'], $limit, $offset);
|
|
}
|
|
|
|
public function countByUser(User $user): int
|
|
{
|
|
return $this->count(['user' => $user]);
|
|
}
|
|
|
|
public function save(WalletTransaction $entity, bool $flush = true): void
|
|
{
|
|
$this->getEntityManager()->persist($entity);
|
|
if ($flush) $this->getEntityManager()->flush();
|
|
}
|
|
}
|