suivi/src/Repository/InterventionRepositoryQuery.php

35 lines
889 B
PHP
Raw Normal View History

<?php
namespace App\Repository;
use App\Core\Repository\RepositoryQuery;
2022-03-06 19:12:11 +01:00
use App\Repository\InterventionRepository as Repository;
2022-03-06 21:14:36 +01:00
use Knp\Component\Pager\PaginatorInterface;
2022-03-06 19:12:11 +01:00
class InterventionRepositoryQuery extends RepositoryQuery
{
public function __construct(Repository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'i', $paginator);
}
2022-03-06 21:14:36 +01:00
protected function filterHandler(string $name, $value)
{
if ('establishment' === $name) {
$this
->leftJoin('.establishmentGroups', 'g')
->andWhere('g.establishment = :establishment')
2022-03-06 21:14:36 +01:00
->setParameter(':establishment', $value)
;
}
}
2022-04-25 11:22:33 +02:00
public function latest(int $max = 5)
{
return $this
->addOrderBy('.date', 'DESC')
->setMaxResults($max)
;
}
}