Repository/UserRepository.php
public function findByUsernameContains($searched_term)
    {
        $qb = $this->createQueryBuilder('u');
        $qb instanceof QueryBuilder;

        $qb->add('where', $qb->expr()->like('u.username', $qb->expr()->lower(':searched_term')))
            ->setParameter('searched_term', $searched_term . '%');

        return $qb->getQuery()->getResult();
    }
public function findByUsernameContains($searched_term)
    {
        $qb = $this->createQueryBuilder('u');
        $qb instanceof QueryBuilder;

        $qb->add('where', $qb->expr()->like('u.username', $qb->expr()->lower(':searched_term')))
            ->setParameter('searched_term', $searched_term . '%');

        return $qb->getQuery()->getResult();
    }
public function findByUsernameContains ( $ searched_term ) { $ qb = $ this -> createQueryBuilder ( 'u' ) ; $ qb instanceof QueryBuilder ; $ qb -> add ( 'where' , $ qb -> expr ( ) -> like ( 'u.username' , $ qb -> expr ( ) -> lower ( ':searched_term' ) ) ) -> setParameter ( 'searched_term' , $ searched_term . '%' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find user by username

@param string $searched_term
Find user by username