* * @method User|null find($id, $lockMode = null, $lockVersion = null) * @method User|null findOneBy(array $criteria, array $orderBy = null) * @method User[] findAll() * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class UserRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, User::class); } public function findOneByIdField(int $id): ?User { return $this->createQueryBuilder('u') ->where('u.id = :id') ->setParameter('id', $id) ->getQuery() ->getOneOrNullResult() ; } public function findOneByAddressField(string $address): ?User { return $this->createQueryBuilder('u') ->where('u.address = :address') ->setParameter('address', $address) ->getQuery() ->getOneOrNullResult() ; } }