mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 14:36:13 +00:00
Repositories adapted for use with person or household
This commit is contained in:
parent
0fcf21bd35
commit
0d96c1f12d
@ -11,8 +11,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\BudgetBundle\Repository;
|
namespace Chill\BudgetBundle\Repository;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChargeRepository.
|
* ChargeRepository.
|
||||||
@ -20,13 +22,35 @@ use DateTime;
|
|||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
* repository methods below.
|
* repository methods below.
|
||||||
*/
|
*/
|
||||||
class ChargeRepository extends \Doctrine\ORM\EntityRepository
|
class ChargeRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
public function findByPersonAndDate(Person $person, DateTime $date, $sort = null)
|
// public function findByPersonAndDate(Person $person, DateTime $date, $sort = null)
|
||||||
|
// {
|
||||||
|
// $qb = $this->createQueryBuilder('c');
|
||||||
|
|
||||||
|
// $qb->where('c.person = :person')
|
||||||
|
// ->andWhere('c.startDate < :date')
|
||||||
|
// ->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
|
||||||
|
// if (null !== $sort) {
|
||||||
|
// $qb->orderBy($sort);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $qb->setParameters([
|
||||||
|
// 'person' => $person,
|
||||||
|
// 'date' => $date,
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// return $qb->getQuery()->getResult();
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function findByEntityAndDate($entity, DateTime $date, $sort = null)
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('c');
|
$qb = $this->createQueryBuilder('c');
|
||||||
|
|
||||||
$qb->where('c.person = :person')
|
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||||
|
|
||||||
|
$qb->where("c.$entityStr = :$entityStr")
|
||||||
->andWhere('c.startDate < :date')
|
->andWhere('c.startDate < :date')
|
||||||
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
|
||||||
@ -35,10 +59,25 @@ class ChargeRepository extends \Doctrine\ORM\EntityRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
'person' => $person,
|
$entityStr => $entity,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function findByHouseholdAndDate(Household $household, DateTime $date)
|
||||||
|
// {
|
||||||
|
// $qb = $this->createQueryBuilder('c');
|
||||||
|
|
||||||
|
// $qb->where('c.household = :household')
|
||||||
|
// ->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
|
||||||
|
// $qb->setParameters([
|
||||||
|
// 'person' => $household,
|
||||||
|
// 'date' => $date,
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// return $qb->getQuery()->getResult();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\BudgetBundle\Repository;
|
namespace Chill\BudgetBundle\Repository;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResourceRepository.
|
* ResourceRepository.
|
||||||
@ -20,13 +22,21 @@ use DateTime;
|
|||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
* This class was generated by the Doctrine ORM. Add your own custom
|
||||||
* repository methods below.
|
* repository methods below.
|
||||||
*/
|
*/
|
||||||
class ResourceRepository extends \Doctrine\ORM\EntityRepository
|
class ResourceRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
public function findByPersonAndDate(Person $person, DateTime $date, $sort = null)
|
|
||||||
|
// public function findByEntity($entity)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function findByEntityAndDate($entity, DateTime $date, $sort = null)
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('c');
|
$qb = $this->createQueryBuilder('c');
|
||||||
|
|
||||||
$qb->where('c.person = :person')
|
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||||
|
|
||||||
|
$qb->where("c.$entityStr = :$entityStr")
|
||||||
->andWhere('c.startDate < :date')
|
->andWhere('c.startDate < :date')
|
||||||
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||||
|
|
||||||
@ -35,10 +45,11 @@ class ResourceRepository extends \Doctrine\ORM\EntityRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$qb->setParameters([
|
$qb->setParameters([
|
||||||
'person' => $person,
|
$entityStr => $entity,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user