suivi/src/Repository/InterventionRepositoryQuery.php

35 lines
889 B
PHP

<?php
namespace App\Repository;
use App\Core\Repository\RepositoryQuery;
use App\Repository\InterventionRepository as Repository;
use Knp\Component\Pager\PaginatorInterface;
class InterventionRepositoryQuery extends RepositoryQuery
{
public function __construct(Repository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'i', $paginator);
}
protected function filterHandler(string $name, $value)
{
if ('establishment' === $name) {
$this
->leftJoin('.establishmentGroups', 'g')
->andWhere('g.establishment = :establishment')
->setParameter(':establishment', $value)
;
}
}
public function latest(int $max = 5)
{
return $this
->addOrderBy('.date', 'DESC')
->setMaxResults($max)
;
}
}