mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: update database relation
This commit is contained in:
@@ -28,9 +28,16 @@ class Nameserver
|
||||
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)]
|
||||
private array $status = [];
|
||||
|
||||
/**
|
||||
* @var Collection<int, Domain>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Domain::class, mappedBy: 'nameservers')]
|
||||
private Collection $domains;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->nameserverEntities = new ArrayCollection();
|
||||
$this->domains = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getHandle(): ?string
|
||||
@@ -102,4 +109,31 @@ class Nameserver
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Domain>
|
||||
*/
|
||||
public function getDomains(): Collection
|
||||
{
|
||||
return $this->domains;
|
||||
}
|
||||
|
||||
public function addDomain(Domain $domain): static
|
||||
{
|
||||
if (!$this->domains->contains($domain)) {
|
||||
$this->domains->add($domain);
|
||||
$domain->addNameserver($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDomain(Domain $domain): static
|
||||
{
|
||||
if ($this->domains->removeElement($domain)) {
|
||||
$domain->removeNameserver($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user