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:
@@ -73,10 +73,17 @@ class Connector
|
||||
#[Groups(['connector:list'])]
|
||||
protected int $watchlistCount;
|
||||
|
||||
/**
|
||||
* @var Collection<int, DomainPurchase>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: DomainPurchase::class, mappedBy: 'connector')]
|
||||
private Collection $domainPurchases;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Uuid::v4();
|
||||
$this->watchlists = new ArrayCollection();
|
||||
$this->domainPurchases = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?string
|
||||
@@ -166,4 +173,34 @@ class Connector
|
||||
{
|
||||
return $this->watchlists->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->setConnector($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->getConnector() === $this) {
|
||||
$domainPurchase->setConnector(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
132
src/Entity/DomainPurchase.php
Normal file
132
src/Entity/DomainPurchase.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Config\ConnectorProvider;
|
||||
use App\Repository\DomainPurchaseRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: DomainPurchaseRepository::class)]
|
||||
class DomainPurchase
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: 'uuid')]
|
||||
private ?string $id;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'domainPurchases')]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'ldh_name', nullable: false)]
|
||||
private ?Domain $domain = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?\DateTimeImmutable $domainUpdatedAt = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $domainOrderedAt = null;
|
||||
|
||||
#[ORM\Column(enumType: ConnectorProvider::class)]
|
||||
private ?ConnectorProvider $connectorProvider = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'domainPurchases')]
|
||||
private ?Connector $connector = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'domainPurchases')]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?\DateTimeImmutable $domainDeletedAt = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Uuid::v4();
|
||||
}
|
||||
|
||||
public function getId(): ?string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getDomain(): ?Domain
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
|
||||
public function setDomain(?Domain $domain): static
|
||||
{
|
||||
$this->domain = $domain;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDomainUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->domainUpdatedAt;
|
||||
}
|
||||
|
||||
public function setDomainUpdatedAt(\DateTimeImmutable $domainUpdatedAt): static
|
||||
{
|
||||
$this->domainUpdatedAt = $domainUpdatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDomainOrderedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->domainOrderedAt;
|
||||
}
|
||||
|
||||
public function setDomainOrderedAt(?\DateTimeImmutable $domainOrderedAt): static
|
||||
{
|
||||
$this->domainOrderedAt = $domainOrderedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConnectorProvider(): ?ConnectorProvider
|
||||
{
|
||||
return $this->connectorProvider;
|
||||
}
|
||||
|
||||
public function setConnectorProvider(ConnectorProvider $connectorProvider): static
|
||||
{
|
||||
$this->connectorProvider = $connectorProvider;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConnector(): ?Connector
|
||||
{
|
||||
return $this->connector;
|
||||
}
|
||||
|
||||
public function setConnector(?Connector $connector): static
|
||||
{
|
||||
$this->connector = $connector;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDomainDeletedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->domainDeletedAt;
|
||||
}
|
||||
|
||||
public function setDomainDeletedAt(\DateTimeImmutable $domainDeletedAt): static
|
||||
{
|
||||
$this->domainDeletedAt = $domainDeletedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -89,10 +89,17 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[Groups(['user:register'])]
|
||||
private ?string $plainPassword = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, DomainPurchase>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: DomainPurchase::class, mappedBy: 'user')]
|
||||
private Collection $domainPurchases;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->watchlists = new ArrayCollection();
|
||||
$this->connectors = new ArrayCollection();
|
||||
$this->domainPurchases = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -262,4 +269,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
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->setUser($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->getUser() === $this) {
|
||||
$domainPurchase->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user