src/Entity/Localisation.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LocalisationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use phpDocumentor\Reflection\Types\Integer;
  8. #[ORM\Entity(repositoryClassLocalisationRepository::class)]
  9. class Localisation
  10. {
  11.     //Déclarations de variables
  12.     #[ORM\Id]
  13.     #[ORM\Column(name'id_localisation',type'integer'nullablefalse)]
  14.     //Spécifie que la valeur générée est un ID auto-incrémenté
  15.     #[ORM\GeneratedValue(strategy:'IDENTITY')]
  16.     private ?int $id;
  17.     #[ORM\Column(length:255,nullable:true)]
  18.     private ?string $ville null;
  19.     #[ORM\Column(length:255,nullable:true)]
  20.     private ?string $departement null;
  21.     #[ORM\Column(length:255,nullable:true)]
  22.     private ?string $region null;
  23.     #[ORM\Column(length:255,nullable:true)]
  24.     private ?string $pays null;
  25.     //Associations
  26.     #[ORM\OneToMany(mappedBy:'localisation'targetEntityModel::class, orphanRemovaltrue)]
  27.     private ?Collection $models;
  28.     //Constructeur
  29.     public function __construct()
  30.     {
  31.         $this->models = new ArrayCollection();
  32.     }
  33.     //Getters et Setters
  34.     //Fonctions des variables
  35.     /**
  36.      * @return int|null
  37.      */
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     /**
  43.      * @return string|null
  44.      */
  45.     public function getVille(): ?string
  46.     {
  47.         return $this->ville;
  48.     }
  49.     /**
  50.      * @param string|null $ville
  51.      */
  52.     public function setVille(?string $ville): void
  53.     {
  54.         $this->ville $ville;
  55.     }
  56.     /**
  57.      * @return string|null
  58.      */
  59.     public function getDepartement(): ?string
  60.     {
  61.         return $this->departement;
  62.     }
  63.     /**
  64.      * @param string|null $departement
  65.      */
  66.     public function setDepartement(?string $departement): void
  67.     {
  68.         $this->departement $departement;
  69.     }
  70.     /**
  71.      * @return string|null
  72.      */
  73.     public function getRegion(): ?string
  74.     {
  75.         return $this->region;
  76.     }
  77.     /**
  78.      * @param string|null $region
  79.      */
  80.     public function setRegion(?string $region): void
  81.     {
  82.         $this->region $region;
  83.     }
  84.     /**
  85.      * @return string|null
  86.      */
  87.     public function getPays(): ?string
  88.     {
  89.         return $this->pays;
  90.     }
  91.     /**
  92.      * @param string|null $pays
  93.      */
  94.     public function setPays(?string $pays): void
  95.     {
  96.         $this->pays $pays;
  97.     }
  98.     //Fonction des collections
  99.     /**
  100.      * @return Collection<int, Model>
  101.      */
  102.     public function getModels(): Collection
  103.     {
  104.         return $this->models;
  105.     }
  106.     public function addModel(Model $model): self
  107.     {
  108.         if (!$this->models->contains($model)) {
  109.             $this->models->add($model);
  110.             $model->addLocalisation($this);
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeModel(Model $model): self
  115.     {
  116.         if ($this->models->removeElement($model)) {
  117.             // set the owning side to null (unless already changed)
  118.             if ($model->getLocalisation() === $this) {
  119.                 $model->addLocalisation(null);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124.     public function __toString(): string
  125.     {
  126.         return $this->ville;
  127.     }
  128. }