profiles->createQueryBuilder('p') ->andWhere('p.isActive = :active') ->setParameter('active', true) ->orderBy('p.firstName', 'ASC') ->getQuery() ->getResult() ; return new JsonResponse(array_map(static function ($profile): array { return [ 'id' => $profile->getId(), 'firstName' => $profile->getFirstName(), 'lastName' => $profile->getLastName(), 'hasPassword' => null !== $profile->getPassword() && '' !== $profile->getPassword(), ]; }, $items)); } }