mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
person: do not suggest the current household of the person
This commit is contained in:
parent
dcf5f1ed66
commit
3417aa8207
@ -47,13 +47,22 @@ class HouseholdApiController extends ApiController
|
||||
$count = $this->householdRepository->countByAccompanyingPeriodParticipation($person);
|
||||
$paginator = $this->getPaginatorFactory()->create($count);
|
||||
|
||||
if ($count === 0) {
|
||||
$households = [];
|
||||
} else {
|
||||
$households = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
|
||||
if ($count !== 0) {
|
||||
$allHouseholds = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
|
||||
$paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
||||
}
|
||||
$currentHouseholdPerson = $person->getCurrentHousehold();
|
||||
|
||||
foreach ($allHouseholds as $h) {
|
||||
if ($h !== $currentHouseholdPerson) {
|
||||
array_push($households, $h);
|
||||
}
|
||||
}
|
||||
if (null !== $currentHouseholdPerson) {
|
||||
$count = $count - 1;
|
||||
$paginator = $this->getPaginatorFactory()->create($count);
|
||||
}
|
||||
}
|
||||
$collection = new Collection($households, $paginator);
|
||||
|
||||
return $this->json($collection, Response::HTTP_OK, [],
|
||||
|
Loading…
x
Reference in New Issue
Block a user