✨ feat(Contrats): Preparation pour le développement des etats des lieux sur etl.ludikevent.fr
This commit is contained in:
40
migrations/Version20260129122052.php
Normal file
40
migrations/Version20260129122052.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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 Version20260129122052 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('CREATE TABLE etat_lieux (id SERIAL NOT NULL, contrat_id INT DEFAULT NULL, prestataire_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_D8D384171823061F ON etat_lieux (contrat_id)');
|
||||
$this->addSql('CREATE INDEX IDX_D8D38417BE3DB2B7 ON etat_lieux (prestataire_id)');
|
||||
$this->addSql('CREATE TABLE prestaire (id SERIAL NOT NULL, email VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, surname VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('ALTER TABLE etat_lieux ADD CONSTRAINT FK_D8D384171823061F FOREIGN KEY (contrat_id) REFERENCES contrats (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE etat_lieux ADD CONSTRAINT FK_D8D38417BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestaire (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
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 etat_lieux DROP CONSTRAINT FK_D8D384171823061F');
|
||||
$this->addSql('ALTER TABLE etat_lieux DROP CONSTRAINT FK_D8D38417BE3DB2B7');
|
||||
$this->addSql('DROP TABLE etat_lieux');
|
||||
$this->addSql('DROP TABLE prestaire');
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,9 @@ class Contrats
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $cautionState = null;
|
||||
|
||||
#[ORM\OneToOne(mappedBy: 'contrat', cascade: ['persist', 'remove'])]
|
||||
private ?EtatLieux $etatLieux = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->contratsPayments = new ArrayCollection();
|
||||
@@ -830,6 +833,28 @@ class Contrats
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEtatLieux(): ?EtatLieux
|
||||
{
|
||||
return $this->etatLieux;
|
||||
}
|
||||
|
||||
public function setEtatLieux(?EtatLieux $etatLieux): static
|
||||
{
|
||||
// unset the owning side of the relation if necessary
|
||||
if ($etatLieux === null && $this->etatLieux !== null) {
|
||||
$this->etatLieux->setContrat(null);
|
||||
}
|
||||
|
||||
// set the owning side of the relation if necessary
|
||||
if ($etatLieux !== null && $etatLieux->getContrat() !== $this) {
|
||||
$etatLieux->setContrat($this);
|
||||
}
|
||||
|
||||
$this->etatLieux = $etatLieux;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
50
src/Entity/EtatLieux.php
Normal file
50
src/Entity/EtatLieux.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\EtatLieuxRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EtatLieuxRepository::class)]
|
||||
class EtatLieux
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\OneToOne(inversedBy: 'etatLieux', cascade: ['persist', 'remove'])]
|
||||
private ?Contrats $contrat = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'etatLieuxes')]
|
||||
private ?Prestaire $prestataire = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getContrat(): ?Contrats
|
||||
{
|
||||
return $this->contrat;
|
||||
}
|
||||
|
||||
public function setContrat(?Contrats $contrat): static
|
||||
{
|
||||
$this->contrat = $contrat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrestataire(): ?Prestaire
|
||||
{
|
||||
return $this->prestataire;
|
||||
}
|
||||
|
||||
public function setPrestataire(?Prestaire $prestataire): static
|
||||
{
|
||||
$this->prestataire = $prestataire;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
123
src/Entity/Prestaire.php
Normal file
123
src/Entity/Prestaire.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PrestaireRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PrestaireRepository::class)]
|
||||
class Prestaire
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, EtatLieux>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: EtatLieux::class, mappedBy: 'prestataire')]
|
||||
private Collection $etatLieuxes;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $surname = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $phone = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->etatLieuxes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, EtatLieux>
|
||||
*/
|
||||
public function getEtatLieuxes(): Collection
|
||||
{
|
||||
return $this->etatLieuxes;
|
||||
}
|
||||
|
||||
public function addEtatLieux(EtatLieux $etatLieux): static
|
||||
{
|
||||
if (!$this->etatLieuxes->contains($etatLieux)) {
|
||||
$this->etatLieuxes->add($etatLieux);
|
||||
$etatLieux->setPrestataire($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeEtatLieux(EtatLieux $etatLieux): static
|
||||
{
|
||||
if ($this->etatLieuxes->removeElement($etatLieux)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($etatLieux->getPrestataire() === $this) {
|
||||
$etatLieux->setPrestataire(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSurname(): ?string
|
||||
{
|
||||
return $this->surname;
|
||||
}
|
||||
|
||||
public function setSurname(string $surname): static
|
||||
{
|
||||
$this->surname = $surname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhone(): ?string
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone(string $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
src/Repository/EtatLieuxRepository.php
Normal file
43
src/Repository/EtatLieuxRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\EtatLieux;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<EtatLieux>
|
||||
*/
|
||||
class EtatLieuxRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EtatLieux::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return EtatLieux[] Returns an array of EtatLieux objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('e')
|
||||
// ->andWhere('e.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('e.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?EtatLieux
|
||||
// {
|
||||
// return $this->createQueryBuilder('e')
|
||||
// ->andWhere('e.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
43
src/Repository/PrestaireRepository.php
Normal file
43
src/Repository/PrestaireRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Prestaire;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Prestaire>
|
||||
*/
|
||||
class PrestaireRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Prestaire::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Prestaire[] Returns an array of Prestaire objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('p.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Prestaire
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user