2022-03-06 18:25:46 +01:00
|
|
|
<?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 18:25:46 +01:00
|
|
|
|
2022-03-06 19:12:11 +01:00
|
|
|
class InterventionRepositoryQuery extends RepositoryQuery
|
2022-03-06 18:25:46 +01:00
|
|
|
{
|
|
|
|
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
|
2022-05-17 22:07:44 +02:00
|
|
|
->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)
|
|
|
|
;
|
|
|
|
}
|
2022-03-06 18:25:46 +01:00
|
|
|
}
|