mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 03:08:25 +00:00 
			
		
		
		
	person: do not suggest the current household of the person
This commit is contained in:
		@@ -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,
 | 
			
		||||
        $households = [];
 | 
			
		||||
        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, [],
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user