mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add domain_purchase table
This commit is contained in:
@@ -156,6 +156,12 @@ class Domain
|
||||
|
||||
private ?int $expiresInDays;
|
||||
|
||||
/**
|
||||
* @var Collection<int, DomainPurchase>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: DomainPurchase::class, mappedBy: 'domain', orphanRemoval: true)]
|
||||
private Collection $domainPurchases;
|
||||
|
||||
private const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value];
|
||||
private const IMPORTANT_STATUS = [
|
||||
'redemption period',
|
||||
@@ -179,6 +185,7 @@ class Domain
|
||||
$this->deleted = false;
|
||||
$this->domainStatuses = new ArrayCollection();
|
||||
$this->dnsKey = new ArrayCollection();
|
||||
$this->domainPurchases = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getLdhName(): ?string
|
||||
@@ -516,4 +523,40 @@ class Domain
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, DomainPurchase>
|
||||
*/
|
||||
public function getDomainPurchases(): Collection
|
||||
{
|
||||
return $this->domainPurchases;
|
||||
}
|
||||
|
||||
public function addDomainPurchase(DomainPurchase $domainPurchase): static
|
||||
{
|
||||
if (!$this->domainPurchases->contains($domainPurchase)) {
|
||||
$this->domainPurchases->add($domainPurchase);
|
||||
$domainPurchase->setDomain($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDomainPurchase(DomainPurchase $domainPurchase): static
|
||||
{
|
||||
if ($this->domainPurchases->removeElement($domainPurchase)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($domainPurchase->getDomain() === $this) {
|
||||
$domainPurchase->setDomain(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['domain:item', 'domain:list'])]
|
||||
public function getPurchaseCount(): ?int
|
||||
{
|
||||
return $this->domainPurchases->count();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user