mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Customize query to return ordered active gender entities
This commit is contained in:
parent
8b1d73356f
commit
30ebd00693
@ -17,6 +17,14 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
|
|
||||||
class GenderApiController extends ApiController
|
class GenderApiController extends ApiController
|
||||||
{
|
{
|
||||||
|
protected function customizeQuery(string $action, Request $request, $query): void
|
||||||
|
{
|
||||||
|
$query
|
||||||
|
->andWhere(
|
||||||
|
$query->expr()->eq('e.active', "'TRUE'")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)
|
||||||
{
|
{
|
||||||
return $query->addOrderBy('e.order', 'ASC');
|
return $query->addOrderBy('e.order', 'ASC');
|
||||||
|
@ -24,4 +24,14 @@ class GenderRepository extends ServiceEntityRepository
|
|||||||
{
|
{
|
||||||
parent::__construct($registry, Gender::class);
|
parent::__construct($registry, Gender::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findByActiveOrdered(): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('g')
|
||||||
|
->select('g')
|
||||||
|
->where('g.active = True')
|
||||||
|
->orderBy('g.order', 'ASC')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user