|
|
@@ -77,6 +77,8 @@ class BankAccount
|
|
|
|
|
|
#[ORM\ManyToMany(targetEntity: Organization::class, inversedBy: 'bankAccounts')]
|
|
|
#[ORM\JoinTable(name: 'organization_bankaccount')]
|
|
|
+ #[ORM\JoinColumn(name: 'bankAccount_id', referencedColumnName: 'id', unique: true)]
|
|
|
+ #[ORM\InverseJoinColumn(name: 'organization_id', referencedColumnName: 'id')]
|
|
|
private Collection $organization;
|
|
|
|
|
|
#[Pure] public function __construct()
|
|
|
@@ -218,6 +220,7 @@ class BankAccount
|
|
|
{
|
|
|
if (!$this->organization->contains($organization)) {
|
|
|
$this->organization[] = $organization;
|
|
|
+ $organization->addBankAccount($this);
|
|
|
}
|
|
|
|
|
|
return $this;
|
|
|
@@ -225,7 +228,9 @@ class BankAccount
|
|
|
|
|
|
public function removeOrganization(Organization $organization): self
|
|
|
{
|
|
|
- $this->organization->removeElement($organization);
|
|
|
+ if ($this->organization->removeElement($organization)) {
|
|
|
+ $organization->removeBankAccount($this);
|
|
|
+ }
|
|
|
|
|
|
return $this;
|
|
|
}
|