src/Entity/TypeCollection.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TypeCollectionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassTypeCollectionRepository::class)]
  8. class TypeCollection
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue(strategy:'IDENTITY')]
  12.     #[ORM\Column(name'id_type_collection',type'integer'nullablefalse)]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $nom null;
  16.     #[ORM\OneToMany(mappedBy'typeCollection'targetEntityModel::class)]
  17.     private Collection $models;
  18.     #[ORM\ManyToMany(targetEntityCategorie::class, inversedBy'typeCollections')]
  19.     #[ORM\JoinTable(name:'typeCollection_categorie')]
  20.     #[ORM\JoinColumn(name'id_type_collection'referencedColumnName'id_type_collection')]
  21.     #[ORM\InverseJoinColumn(name'id_categorie'referencedColumnName'id_categorie')]
  22.     private Collection $categories;
  23.     #[ORM\OneToMany(mappedBy'typeCollection'targetEntityMatiere::class)]
  24.     private Collection $matieres;
  25.     #[ORM\OneToMany(mappedBy'typeCollection'targetEntityForme::class)]
  26.     private Collection $formes;
  27.     public function __construct()
  28.     {
  29.         $this->models = new ArrayCollection();
  30.         $this->categories = new ArrayCollection();
  31.         $this->matieres = new ArrayCollection();
  32.         $this->formes = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getNom(): ?string
  39.     {
  40.         return $this->nom;
  41.     }
  42.     public function setNom(string $nom): self
  43.     {
  44.         $this->nom $nom;
  45.         return $this;
  46.     }
  47.     /**
  48.      * @return Collection<int, Model>
  49.      */
  50.     public function getModels(): Collection
  51.     {
  52.         return $this->models;
  53.     }
  54.     public function addModel(Model $model): self
  55.     {
  56.         if (!$this->models->contains($model)) {
  57.             $this->models->add($model);
  58.             $model->setTypeCollection($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeModel(Model $model): self
  63.     {
  64.         if ($this->models->removeElement($model)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($model->getTypeCollection() === $this) {
  67.                 $model->setTypeCollection(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Categorie>
  74.      */
  75.     public function getCategories(): Collection
  76.     {
  77.         return $this->categories;
  78.     }
  79.     public function addCategory(Categorie $category): self
  80.     {
  81.         if (!$this->categories->contains($category)) {
  82.             $this->categories->add($category);
  83.         }
  84.         return $this;
  85.     }
  86.     public function removeCategory(Categorie $category): self
  87.     {
  88.         $this->categories->removeElement($category);
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, Matiere>
  93.      */
  94.     public function getMatieres(): Collection
  95.     {
  96.         return $this->matieres;
  97.     }
  98.     public function addMatiere(Matiere $matiere): self
  99.     {
  100.         if (!$this->matieres->contains($matiere)) {
  101.             $this->matieres->add($matiere);
  102.             $matiere->setTypeCollection($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeMatiere(Matiere $matiere): self
  107.     {
  108.         if ($this->matieres->removeElement($matiere)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($matiere->getTypeCollection() === $this) {
  111.                 $matiere->setTypeCollection(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, Forme>
  118.      */
  119.     public function getFormes(): Collection
  120.     {
  121.         return $this->formes;
  122.     }
  123.     public function addForm(Forme $forme): self
  124.     {
  125.         if (!$this->formes->contains($forme)) {
  126.             $this->formes->add($forme);
  127.             $forme->setTypeCollection($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeForme(Forme $forme): self
  132.     {
  133.         if ($this->formes->removeElement($forme)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($forme->getTypeCollection() === $this) {
  136.                 $forme->setTypeCollection(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     public function __toString(): string
  142.     {
  143.         return $this->nom;
  144.     }
  145. }