src/Entity/Etagere.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EtagereRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use phpDocumentor\Reflection\Types\Integer;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassEtagereRepository::class)]
  9. class Etagere
  10. {
  11. //Déclarations des variables
  12.     #[ORM\Id]
  13.     #[ORM\Column(name'id_etagere',type'integer'nullablefalse)]
  14.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  15.     private ?int $id;
  16.     #[ORM\Column(length255nullablefalse)]
  17.     private ?string $nom null;
  18.     //Associations
  19.     //On ajoute la relation ManyToOne où Photo est le propriétaire (=Many), (=inversedBy)
  20.     #[ORM\ManyToOne(targetEntityArmoire::class, inversedBy'etageres')]
  21.     #[ORM\JoinColumn(referencedColumnName'id_armoire'nullablefalse)]
  22.     private ?Armoire $armoire null;
  23.     #[ORM\OneToMany(mappedBy:'etagere'targetEntityClasseur::class, orphanRemovaltrue)]
  24.     private ?Collection $classeurs;
  25.     //Constructeur
  26.     public function __construct()
  27.     {
  28.         $this->classeurs = new ArrayCollection();
  29.     }
  30.     //Getters et Setters
  31.     /**
  32.      * @return int|null
  33.      */
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     /**
  39.      * @return string|null
  40.      */
  41.     public function getNom(): ?string
  42.     {
  43.         return $this->nom;
  44.     }
  45.     /**
  46.      * @param string|null $nom
  47.      */
  48.     public function setNom(?string $nom): void
  49.     {
  50.         $this->nom $nom;
  51.     }
  52.     /**
  53.      * @return Armoire|null
  54.      */
  55.     public function getArmoire(): ?Armoire
  56.     {
  57.         return $this->armoire;
  58.     }
  59.     /**
  60.      * @param Armoire|null $armoire
  61.      */
  62.     public function setArmoire(?Armoire $armoire): void
  63.     {
  64.         $this->armoire $armoire;
  65.     }
  66.     //Fonctions des collections
  67.     /**
  68.      * @return Collection<int, Classeur>
  69.      */
  70.     public function getClasseur(): Collection
  71.     {
  72.         return $this->classeurs;
  73.     }
  74.     public function addClasseur(Classeur $classeur): self
  75.     {
  76.         if (!$this->classeurs->contains($classeur)) {
  77.             $this->classeurs->add($classeur);
  78.             $classeur->setEtagere($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeClasseur(Classeur $classeur): self
  83.     {
  84.         if ($this->classeurs->removeElement($classeur)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($classeur->getEtagere() === $this) {
  87.                 $classeur->setEtagere(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92.     public function __toString(): string
  93.     {
  94.         return $this->nom ?? '';
  95.     }
  96. }