I'm currently trying to apply text to whether the events inside my event group have spaces available or are sold out.
My loop looks at each event in the event group and returns whether they are sold out or available for each specific event. My issue is that it's just returning the same value for both events rather than looking at each specific event so it is returning the wrong value.
It adds these to an array and implodes each one out, but the second value is always wrong. Any ideas?
Even if the second event has hit it's capacity value, it still shows as available
public function getAreEventsAvailableStringMultiple() {
$availability = null;
foreach ($this->events as $event) {
$availability[] = $this->getAreEventsAvailable() ? 'Spaces still available' : 'Sold Out';
}
return implode(' <br/> ', $availability);
}
Other function
public function getAreEventsAvailable() {
foreach ($this->events as $event) {
if ($event->getRemainingCapacity() > 0) {
return true;
}
}
return false;
}
$this->getAreEventsAvailable()? I think you are missing param$this->getAreEventsAvailable($event)