X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FUserBundle%2FRepository%2FUserRepository.php;h=be693d3b1312f6e86aae660c3798ee2b1e5d6530;hb=2490f61dca635026a3eb9b5e9b6978b1981b1172;hp=445edb3c1077cb2826e2937cb7fccdff2ae4e2be;hpb=68003139e133835805b143b62c4407f19b495dab;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index 445edb3c..be693d3b 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -3,6 +3,8 @@ namespace Wallabag\UserBundle\Repository; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; +use Wallabag\UserBundle\Entity\User; class UserRepository extends EntityRepository { @@ -48,8 +50,34 @@ class UserRepository extends EntityRepository { return $this->createQueryBuilder('u') ->select('count(u)') - ->andWhere('u.expired = false') + ->andWhere('u.enabled = true') ->getQuery() ->getSingleScalarResult(); } + + /** + * Count how many users are existing. + * + * @return int + */ + public function getSumUsers() + { + return $this->createQueryBuilder('u') + ->select('count(u)') + ->getQuery() + ->getSingleScalarResult(); + } + + /** + * Retrieves users filtered with a search term. + * + * @param string $term + * + * @return QueryBuilder + */ + public function getQueryBuilderForSearch($term) + { + return $this->createQueryBuilder('u') + ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%'); + } }