У меня есть объект досье с отношением «один ко многим» к Echeance:
Код: Выделить всё
#[ORM\OneToMany(mappedBy: 'dossier', targetEntity: Echeance::class, orphanRemoval: true)]
private Collection $echeances;
Код: Выделить всё
foreach ($dossier->getEcheances() as $echeance) {
if (!$this->hasActiveReglement($echeance)) {
$dossier->removeEcheance($echeance);
}
}
Код: Выделить всё
foreach ($dossier->getEcheances()->toArray() as $echeance) {
if (!$this->hasActiveReglement($echeance)) {
$dossier->removeEcheance($echeance);
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... reach-loop
Мобильная версия