feat: update database relation

This commit is contained in:
Maël Gangloff
2024-07-11 22:20:20 +02:00
parent bad27c7b42
commit 6aad09297f
11 changed files with 146 additions and 83 deletions

View File

@@ -38,16 +38,27 @@ class Domain
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
private array $status = [];
/**
* @var Collection<int, BookmarkList>
*/
#[ORM\ManyToMany(targetEntity: BookmarkList::class, mappedBy: 'domains')]
private Collection $bookmarkLists;
/**
* @var Collection<int, Nameserver>
*/
#[ORM\ManyToMany(targetEntity: Nameserver::class, mappedBy: 'handle')]
#[ORM\ManyToMany(targetEntity: Nameserver::class, inversedBy: 'domains')]
#[ORM\JoinTable(name: 'domain_nameservers',
joinColumns: [new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle'), new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'nameserver_handle', referencedColumnName: 'handle')]
)]
private Collection $nameservers;
public function __construct()
{
$this->events = new ArrayCollection();
$this->domainEntities = new ArrayCollection();
$this->bookmarkLists = new ArrayCollection();
$this->nameservers = new ArrayCollection();
}
@@ -162,6 +173,33 @@ class Domain
return $this;
}
/**
* @return Collection<int, BookmarkList>
*/
public function getBookmarkLists(): Collection
{
return $this->bookmarkLists;
}
public function addBookmarkList(BookmarkList $bookmarkList): static
{
if (!$this->bookmarkLists->contains($bookmarkList)) {
$this->bookmarkLists->add($bookmarkList);
$bookmarkList->addDomain($this);
}
return $this;
}
public function removeBookmarkList(BookmarkList $bookmarkList): static
{
if ($this->bookmarkLists->removeElement($bookmarkList)) {
$bookmarkList->removeDomain($this);
}
return $this;
}
/**
* @return Collection<int, Nameserver>
*/