Tighten link between Accountings and owner entities

This commit is contained in:
2024-03-06 16:19:28 +01:00
parent 5cd0a8e3b2
commit 57c8142fc9
5 changed files with 70 additions and 25 deletions
+10
View File
@@ -2,6 +2,7 @@
namespace App\Repository;
use App\Entity\Accounting;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -40,6 +41,15 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
$this->getEntityManager()->flush();
}
public function findOneByAccounting(Accounting $accounting): ?User
{
return $this->createQueryBuilder('u')
->andWhere('u.accounting = :val')
->setParameter('val', $accounting->getId())
->getQuery()
->getOneOrNullResult();
}
// /**
// * @return User[] Returns an array of User objects
// */