. */ namespace App\Repository\Parts; use App\Entity\Parts\Part; use App\Repository\AbstractPartsContainingRepository; use Doctrine\ORM\QueryBuilder; class StorelocationRepository extends AbstractPartsContainingRepository { public function getParts(object $element, array $order_by = ['name' => 'ASC']): array { $qb = new QueryBuilder($this->getEntityManager()); $qb->select('part') ->from(Part::class, 'part') ->leftJoin('part.partLots', 'lots') ->where('lots.storage_location = ?1') ->setParameter(1, $element); foreach ($order_by as $field => $order) { $qb->addOrderBy('part.' . $field, $order); } return $qb->getQuery()->getResult(); } public function getPartsCount(object $element): int { $qb = new QueryBuilder($this->getEntityManager()); $qb->select('COUNT(part.id)') ->from(Part::class, 'part') ->leftJoin('part.partLots', 'lots') ->where('lots.storage_location = ?1') ->setParameter(1, $element); return (int) $qb->getQuery()->getSingleScalarResult(); } }