From 8c3be2df3b9be13cda1f8e35df9744680a250c8c Mon Sep 17 00:00:00 2001 From: mepiphana2023 Date: Mon, 25 Nov 2024 10:37:04 +0100 Subject: [PATCH] suppr table ville --- src/Entity/Lieu.php | 48 +++++++++++++-------- src/Entity/Ville.php | 94 ----------------------------------------- src/Form/SortieType.php | 8 ---- 3 files changed, 30 insertions(+), 120 deletions(-) delete mode 100644 src/Entity/Ville.php diff --git a/src/Entity/Lieu.php b/src/Entity/Lieu.php index 7cfafa6..bb0579f 100644 --- a/src/Entity/Lieu.php +++ b/src/Entity/Lieu.php @@ -28,16 +28,18 @@ class Lieu #[ORM\Column(nullable: true)] private ?float $longitude = null; + #[ORM\Column(length: 255)] + private ?string $ville = null; + + #[ORM\Column(type: 'integer')] + private ?int $codePostal = null; + /** * @var Collection */ #[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'lieu')] private Collection $sorties; - #[ORM\ManyToOne(inversedBy: 'lieux')] - #[ORM\JoinColumn(name: 'ville_id', referencedColumnName: 'id_ville', nullable: false)] - private ?Ville $ville = null; - public function __construct() { $this->sorties = new ArrayCollection(); @@ -96,6 +98,30 @@ class Lieu return $this; } + public function getVille(): ?string + { + return $this->ville; + } + + public function setVille(string $ville): self + { + $this->ville = $ville; + + return $this; + } + + public function getCodePostal(): ?int + { + return $this->codePostal; + } + + public function setCodePostal(int $codePostal): self + { + $this->codePostal = $codePostal; + + return $this; + } + /** * @return Collection */ @@ -125,18 +151,4 @@ class Lieu return $this; } - - public function getVille(): ?Ville - { - return $this->ville; - } - - public function setVille(?Ville $ville): self - { - $this->ville = $ville; - - return $this; - } - - } diff --git a/src/Entity/Ville.php b/src/Entity/Ville.php deleted file mode 100644 index a187ff9..0000000 --- a/src/Entity/Ville.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ - #[ORM\OneToMany(targetEntity: Lieu::class, mappedBy: 'ville')] - private Collection $lieux; - - public function __construct() - { - $this->lieux = new ArrayCollection(); - } - - public function getIdVille(): ?string - { - return $this->idVille; - } - - public function getNom(): ?string - { - return $this->nom; - } - - public function setNom(string $nom): self - { - $this->nom = $nom; - - return $this; - } - - public function getCodePostal(): ?int - { - return $this->codePostal; - } - - public function setCodePostal(?int $codePostal): self - { - $this->codePostal = $codePostal; - - return $this; - } - - /** - * @return Collection - */ - public function getLieux(): Collection - { - return $this->lieux; - } - - public function addLieu(Lieu $lieu): self - { - if (!$this->lieux->contains($lieu)) { - $this->lieux->add($lieu); - $lieu->setVille($this); - } - - return $this; - } - - public function removeLieu(Lieu $lieu): self - { - if ($this->lieux->removeElement($lieu)) { - // Set the owning side to null (unless already changed) - if ($lieu->getVille() === $this) { - $lieu->setVille(null); - } - } - - return $this; - } -} diff --git a/src/Form/SortieType.php b/src/Form/SortieType.php index b47516e..0ff4429 100644 --- a/src/Form/SortieType.php +++ b/src/Form/SortieType.php @@ -54,14 +54,6 @@ class SortieType extends AbstractType 'required' => false, 'attr' => ['class' => 'form-control'], ]) - ->add('ville', EntityType::class, [ - 'class' => Ville::class, - 'choice_label' => 'nom', - 'mapped' => false, - 'label' => 'Ville', - 'placeholder' => 'Sélectionnez une ville', - 'attr' => ['id' => 'ville-select'], - ]) ->add('lieu', EntityType::class, [ 'class' => Lieu::class, 'choice_label' => 'nom',