diff --git a/src/AppBundle/Repository/PlantRepository.php b/src/AppBundle/Repository/PlantRepository.php index 69bf9ac..2738f74 100644 --- a/src/AppBundle/Repository/PlantRepository.php +++ b/src/AppBundle/Repository/PlantRepository.php @@ -73,16 +73,16 @@ public function countByFarm($farmId) { $qb = $this->getRepository()->createQueryBuilder('p'); - $qb->select('COUNT (p) AS total_crops') + $qb->select('p') ->innerJoin('AppBundle:Seed', 's', 'WITH', 'p.seed = s.id') ->innerJoin('AppBundle:Area', 'a', 'WITH', 'p.area = a.id') ->where('a.field = '.$farmId) ->groupBy('p.seed') ->getQuery(); - - $query = $qb->getQuery()->getOneOrNullResult(); - return (int) $query['total_crops']; + $query = $qb->getQuery()->getResult(); + + return (int) count($query); } /**