namespace Wallabag\UserBundle\Repository;
use Doctrine\ORM\EntityRepository;
+use Doctrine\ORM\QueryBuilder;
+use Wallabag\UserBundle\Entity\User;
class UserRepository extends EntityRepository
{
->getQuery()
->getSingleResult();
}
+
+ /**
+ * Count how many users are enabled.
+ *
+ * @return int
+ */
+ public function getSumEnabledUsers()
+ {
+ return $this->createQueryBuilder('u')
+ ->select('count(u)')
+ ->andWhere('u.enabled = true')
+ ->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 . '%');
+ }
}