src/Entity/Matiere.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MatiereRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use phpDocumentor\Reflection\Types\Integer;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassMatiereRepository::class)]
  9. class Matiere
  10. {
  11.     //Déclarations des variables
  12.     #[ORM\Id]
  13.     #[ORM\Column(name'id_matiere',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(name'nom',length255nullablefalse)]
  18.     private ?string $nom null;
  19.     //Association
  20.     #[ORM\OneToMany(mappedBy:'matiere'targetEntityModel::class, orphanRemovaltrue)]
  21.     private Collection $models;
  22.     #[ORM\ManyToOne(targetEntityTypeCollection::class, inversedBy'matieres')]
  23.     #[ORM\JoinColumn(referencedColumnName'id_type_collection'nullablefalse)]
  24.     private ?TypeCollection $typeCollection null;
  25.     //Constructeur
  26.     public function __construct()
  27.     {
  28.         $this->models = new ArrayCollection();
  29.     }
  30.     //Getters et Setter
  31.     //Fonctions des variables
  32.     /**
  33.      * @return int|null
  34.      */
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     /**
  40.      * @return string|null
  41.      */
  42.     public function getNom(): ?string
  43.     {
  44.         return $this->nom;
  45.     }
  46.     /**
  47.      * @param string|null $nom
  48.      */
  49.     public function setNom(?string $nom): void
  50.     {
  51.         $this->nom $nom;
  52.     }
  53.     //Fonctions des collections
  54.     /**
  55.      * @return Collection<int, Model>
  56.      */
  57.     public function getModels(): Collection
  58.     {
  59.         return $this->models;
  60.     }
  61.     public function addModel(Model $model): self
  62.     {
  63.         if (!$this->models->contains($model)) {
  64.             $this->models->add($model);
  65.             $model->addMatiere($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeModel(Model $model): self
  70.     {
  71.         if ($this->models->removeElement($model)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($model->getMatiere() === $this) {
  74.                 $model->removeMatiere(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79.     public function __toString(): string
  80.     {
  81.         return $this->nom ?? '';
  82.     }
  83.     public function getTypeCollection(): ?TypeCollection
  84.     {
  85.         return $this->typeCollection;
  86.     }
  87.     public function setTypeCollection(?TypeCollection $typeCollection): self
  88.     {
  89.         $this->typeCollection $typeCollection;
  90.         return $this;
  91.     }
  92. }