src/Entity/Armoire.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ArmoireRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassArmoireRepository::class)]
  8. class Armoire
  9. {
  10. //Déclarations des variables
  11.     #[ORM\Id]
  12.     #[ORM\Column(name'id_armoire',type'integer'nullablefalse)]
  13.     //Spécifie que la valeur générée est un ID auto-incrémenté
  14.     #[ORM\GeneratedValue(strategy:'IDENTITY')]
  15.     private ?int $id;
  16.     #[ORM\Column(length255nullablefalse)]
  17.     private ?string $nom null;
  18.     //Association
  19.     #[ORM\OneToMany(mappedBy:'armoire'targetEntityClasseur::class, orphanRemovaltrue)]
  20.     private ?Collection $classeurs;
  21.     #[ORM\OneToMany(mappedBy:'armoire'targetEntityEtagere::class, orphanRemovaltrue)]
  22.     private ?Collection $etageres;
  23.     //Constructeur
  24.     public function __construct()
  25.     {
  26.         $this->classeurs = new ArrayCollection();
  27.         $this->etageres = new ArrayCollection();
  28.     }
  29.     //Getters et Setters
  30.     /**
  31.      * @return int|null
  32.      */
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     /**
  38.      * @return string|null
  39.      */
  40.     public function getNom(): ?string
  41.     {
  42.         return $this->nom;
  43.     }
  44.     /**
  45.      * @param string|null $nom
  46.      */
  47.     public function setNom(?string $nom): void
  48.     {
  49.         $this->nom $nom;
  50.     }
  51.     //Fonctions des collections
  52.     /**
  53.      * @return Collection<int, Classeur>
  54.      */
  55.     public function getClasseurs(): Collection
  56.     {
  57.         return $this->classeurs;
  58.     }
  59.     public function addClasseur(Classeur $classeur): self
  60.     {
  61.         if (!$this->classeurs->contains($classeur)) {
  62.             $this->classeurs->add($classeur);
  63.             $classeur->setArmoire($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeClasseur(Classeur $classeur): self
  68.     {
  69.         if ($this->classeurs->removeElement($classeur)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($classeur->getArmoire() === $this) {
  72.                 $classeur->setArmoire(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, Etagere>
  79.      */
  80.     public function getEtageres(): Collection
  81.     {
  82.         return $this->etageres;
  83.     }
  84.     public function addEtagere(Etagere $etagere): self
  85.     {
  86.         if (!$this->etageres->contains($etagere)) {
  87.             $this->etageres->add($etagere);
  88.             $etagere->setArmoire($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeEtagere(Etagere $etagere): self
  93.     {
  94.         if ($this->etageres->removeElement($etagere)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($etagere->getArmoire() === $this) {
  97.                 $etagere->setArmoire(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function __toString(): string
  103.     {
  104.         return $this->nom ?? '';
  105.     }
  106. }