From c2cfa19e430ddba0d1cba4f18c805adc76fee639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 12 Nov 2021 11:42:17 +0100 Subject: [PATCH] person search: add birthdate and file number --- .../ChillPersonBundle/Search/PersonSearch.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 6d562ec95..994759d0a 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -161,7 +161,8 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface, 'p.firstName', $qb->expr()->literal(' '), 'p.lastName' - ).'AS text' + ).'AS text', + 'p.birthdate' ); } else { $qb->select('p'); @@ -178,7 +179,15 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface, ->addOrderBy('p.lastName'); if ($options['simplify'] ?? false) { - return $qb->getQuery()->getResult(Query::HYDRATE_ARRAY); + return \array_map( + function($row) { + $row['text'] .= ' ('.($row['birthdate'] instanceof \DateTimeInterface ? $row['birthdate']->format('d/m/Y').' - ' : '').'dossier n°'.$row['id'].')'; + + return $row; + } + , + $qb->getQuery()->getResult(Query::HYDRATE_ARRAY) + ); } else { return $qb->getQuery()->getResult(); }