Files
haushalt/backend/src/Repository/TaskSchemaRepository.php
2026-04-14 18:15:05 +02:00

47 lines
1.2 KiB
PHP

<?php
namespace App\Repository;
use App\Collection\TaskSchemaCollection;
use App\Entity\TaskSchema;
use App\Enum\TaskSchemaStatus;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<TaskSchema>
*/
class TaskSchemaRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, TaskSchema::class);
}
public function allSchemas(): TaskSchemaCollection
{
return new TaskSchemaCollection(parent::findAll());
}
/** @return list<TaskSchema> */
public function findActive(): array
{
return $this->createQueryBuilder('s')
->andWhere('s.status = :status')
->setParameter('status', TaskSchemaStatus::Active)
->getQuery()
->getResult();
}
/** @return list<TaskSchema> */
public function findExpired(): array
{
return $this->createQueryBuilder('s')
->andWhere('s.end IS NOT NULL')
->andWhere('s.end < :today')
->setParameter('today', new \DateTimeImmutable('today'))
->getQuery()
->getResult();
}
}