This commit is contained in:
marvin
2024-11-18 16:39:14 +01:00
parent e0935ec69d
commit 2131abdd5f
12 changed files with 932 additions and 138 deletions

141
src/Entity/Lieu.php Normal file
View File

@@ -0,0 +1,141 @@
<?php
namespace App\Entity;
use App\Repository\LieuRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: LieuRepository::class)]
class Lieu
{
#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $idLieu = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $rue = null;
#[ORM\Column(nullable: true)]
private ?float $latitude = null;
#[ORM\Column(nullable: true)]
private ?float $longitude = null;
/**
* @var Collection<int, Sortie>
*/
#[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'lieu')]
private Collection $sorties;
#[ORM\ManyToOne(inversedBy: 'lieux')]
private ?Ville $ville = null;
public function __construct()
{
$this->idLieu = Uuid::v4(); // Génération automatique d'un UUID
$this->sorties = new ArrayCollection();
}
public function getIdLieu(): ?Uuid
{
return $this->idLieu;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getRue(): ?string
{
return $this->rue;
}
public function setRue(?string $rue): self
{
$this->rue = $rue;
return $this;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function setLatitude(?float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function setLongitude(?float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
/**
* @return Collection<int, Sortie>
*/
public function getSorties(): Collection
{
return $this->sorties;
}
public function addSortie(Sortie $sortie): self
{
if (!$this->sorties->contains($sortie)) {
$this->sorties->add($sortie);
$sortie->setLieu($this);
}
return $this;
}
public function removeSortie(Sortie $sortie): self
{
if ($this->sorties->removeElement($sortie)) {
// Set the owning side to null (unless already changed)
if ($sortie->getLieu() === $this) {
$sortie->setLieu(null);
}
}
return $this;
}
public function getVille(): ?Ville
{
return $this->ville;
}
public function setVille(?Ville $ville): self
{
$this->ville = $ville;
return $this;
}
}