47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace AppBundle\Entity;
|
|
use Doctrine\ORM\Query\Expr\OrderBy;
|
|
|
|
/**
|
|
* FewoLodgingRepository
|
|
*
|
|
* This class was generated by the Doctrine ORM. Add your own custom
|
|
* repository methods below.
|
|
*/
|
|
class FewoLodgingRepository extends \Doctrine\ORM\EntityRepository
|
|
{
|
|
/**
|
|
* @param FewoLodging $lodging
|
|
*
|
|
* @return FewoSeason|null
|
|
*/
|
|
public function findLatestSeasonEndForLodging($lodging)
|
|
{
|
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
|
$qb->select('s');
|
|
$qb->from('AppBundle:FewoSeason', 's');
|
|
$qb->innerJoin('s.prices', 'p');
|
|
$qb->where($qb->expr()->eq('p.lodging', $lodging->getId()));
|
|
$qb->addOrderBy('s.toDate', 'DESC');
|
|
$qb->setMaxResults(1);
|
|
return $qb->getQuery()->getOneOrNullResult();
|
|
}
|
|
|
|
|
|
public function findSeasonForLodgingBy($lodging, $fromDate)
|
|
{
|
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
|
$qb->select('s');
|
|
$qb->from('AppBundle:FewoSeason', 's');
|
|
$qb->innerJoin('s.prices', 'p');
|
|
$qb->where($qb->expr()->eq('p.lodging', $lodging->getId()));
|
|
$qb->andWhere('s.fromDate <= :fromDate');
|
|
$qb->andWhere('s.toDate >= :fromDate');
|
|
$qb->setParameter('fromDate', $fromDate);
|
|
$qb->addOrderBy('s.fromDate', 'DESC');
|
|
$qb->setMaxResults(1);
|
|
return $qb->getQuery()->getOneOrNullResult();
|
|
}
|
|
|
|
}
|