mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-26 14:44:32 +00:00
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\User;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<User>
|
|
*
|
|
* @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()
|
|
;
|
|
}
|
|
}
|