2lenet/crudit-bundle
Symfony bundle to rapidly build configurable CRUD back offices with SB Admin layout. Provides list views with pagination, sorting, actions, exports and batch ops, plus datasources, filters, menus, workflows, maps, markdown and Twig helpers.
It is easily possible to apply the result of you filters within your own Controller.
If you want to learn how to create filters and your FilterSet, please read the chapter about filters.
1. Inject your FilterSet and the FilterState in your Controller
private SiteCollecteFilterset $filterset;
private FilterState $filterState;
public function __construct(
SiteCollecteFilterset $filterset,
FilterState $filterState
) {
$this->filterset = $filterset;
$this->filterState = $filterState;
}
2. Then, in your method, create your initial queryBuilder
In the method:
$qb = $this->siteCollecteRepository->findSiteCollecteWithGeoQb();
In the repository:
public function findSiteCollecteWithGeoQb()
{
return $this->createQueryBuilder('root')
->andWhere('root.centreLat IS NOT NULL AND root.centreLng IS NOT NULL OR root.polygone IS NOT NULL')
;
}
3. In your method you can now retrieve your filters, apply your query to them and run the whole thing
$qb = $this->siteCollecteRepository->findSiteCollecteWithGeoQb();
foreach ($this->filterset->getFilters() as $filter) {
$filter->setData($this->filterState->getData($this->filterset->getId(), $filter->getId()));
$filter->apply($qb);
}
$sitesCollectes = $qb->getQuery()->execute();
Tadaaaa, the sitesCollectes take into account both your query in the repository and what you have passed in your filters.
How can I help you explore Laravel packages today?