✨ feat(CustomerDns/Website): Ajoute la relation entre CustomerDns et Website et les champs de Website.
This commit is contained in:
44
migrations/Version20251016123124.php
Normal file
44
migrations/Version20251016123124.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251016123124 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE customer_dns ADD website_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE customer_dns ADD CONSTRAINT FK_CD1E82B718F45C82 FOREIGN KEY (website_id) REFERENCES website (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_CD1E82B718F45C82 ON customer_dns (website_id)');
|
||||
$this->addSql('ALTER TABLE website ADD main_dns VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE website ADD state VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE website ADD title VARCHAR(255) NOT NULL');
|
||||
$this->addSql('ALTER TABLE website ADD type VARCHAR(255) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE customer_dns DROP CONSTRAINT FK_CD1E82B718F45C82');
|
||||
$this->addSql('DROP INDEX IDX_CD1E82B718F45C82');
|
||||
$this->addSql('ALTER TABLE customer_dns DROP website_id');
|
||||
$this->addSql('ALTER TABLE website DROP main_dns');
|
||||
$this->addSql('ALTER TABLE website DROP state');
|
||||
$this->addSql('ALTER TABLE website DROP title');
|
||||
$this->addSql('ALTER TABLE website DROP type');
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\EsyWeb\Website;
|
||||
use App\Repository\CustomerDnsRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -42,6 +43,9 @@ class CustomerDns
|
||||
#[ORM\OneToMany(targetEntity: CustomerDnsEmail::class, mappedBy: 'dns')]
|
||||
private Collection $customerDnsEmails;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'ndd')]
|
||||
private ?Website $website = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->customerDnsEmails = new ArrayCollection();
|
||||
@@ -165,4 +169,16 @@ class CustomerDns
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWebsite(): ?Website
|
||||
{
|
||||
return $this->website;
|
||||
}
|
||||
|
||||
public function setWebsite(?Website $website): static
|
||||
{
|
||||
$this->website = $website;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
namespace App\Entity\EsyWeb;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\CustomerDns;
|
||||
use App\Repository\EsyWeb\WebsiteRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
@@ -21,6 +24,29 @@ class Website
|
||||
#[ORM\Column(type: 'uuid')]
|
||||
private ?Uuid $uuid = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, CustomerDns>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: CustomerDns::class, mappedBy: 'website')]
|
||||
private Collection $ndd;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $mainDns = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $state = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $type = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ndd = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -49,4 +75,82 @@ class Website
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, CustomerDns>
|
||||
*/
|
||||
public function getNdd(): Collection
|
||||
{
|
||||
return $this->ndd;
|
||||
}
|
||||
|
||||
public function addNdd(CustomerDns $ndd): static
|
||||
{
|
||||
if (!$this->ndd->contains($ndd)) {
|
||||
$this->ndd->add($ndd);
|
||||
$ndd->setWebsite($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeNdd(CustomerDns $ndd): static
|
||||
{
|
||||
if ($this->ndd->removeElement($ndd)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($ndd->getWebsite() === $this) {
|
||||
$ndd->setWebsite(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMainDns(): ?string
|
||||
{
|
||||
return $this->mainDns;
|
||||
}
|
||||
|
||||
public function setMainDns(string $mainDns): static
|
||||
{
|
||||
$this->mainDns = $mainDns;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getState(): ?string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function setState(string $state): static
|
||||
{
|
||||
$this->state = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): static
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user