<?phpnamespace App\Entity;use App\Repository\CategorieRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass:CategorieRepository ::class)]class Categorie{ //Déclarations des variables #[ORM\Id] #[ORM\Column(name: 'id_categorie',type: 'integer',nullable: false)] #[ORM\GeneratedValue(strategy:'IDENTITY')] private ?int $id; #[ORM\Column(length: 255, nullable: false)] private ?string $nom = null; //Associations #[ORM\OneToMany(mappedBy:'categorie', targetEntity: SousCategorie::class)] private Collection $sousCategories; //Association bidirectionnelle #[ORM\ManyToMany(targetEntity: Model::class, mappedBy:'categories')] private ?Collection $models; #[ORM\ManyToMany(targetEntity: TypeCollection::class, mappedBy: 'categories')] private Collection $typeCollections; //Constructeur public function __construct() { $this->sousCategories = new ArrayCollection(); $this->models = new ArrayCollection(); $this->typeCollections = new ArrayCollection(); } //Getters et Setters /** * @return int|null */ public function getId(): ?int { return $this->id; } /** * @return string|null */ public function getNom(): ?string { return $this->nom; } /** * @param string|null $nom */ public function setNom(?string $nom): void { $this->nom = $nom; } /** * @return Collection<int, SousCategorie> */ public function getSousCategories(): Collection { return $this->sousCategories; } public function addSousCategorie(SousCategorie $sousCategorie): self { if (!$this->sousCategories->contains($sousCategorie)) { $this->sousCategories->add($sousCategorie); $sousCategorie->addCategorie($this); } return $this; } public function removeSousCategorie(SousCategorie $sousCategorie): self { if ($this->sousCategories->removeElement($sousCategorie)) { // set the owning side to null (unless already changed) if ($sousCategorie->getCategorie() === $this) { $sousCategorie->removeCategorie(null); } } return $this; } /** * @return Collection<int, Model> */ public function getModels(): Collection { return $this->models; } public function addModel(Model $model): self { if (!$this->models->contains($model)) { $this->models->add($model); $model->addCategorie($this); } return $this; } public function removeModel(Model $model): self { if ($this->models->removeElement($model)) { // set the owning side to null (unless already changed) if ($model->getCategories() === $this) { $model->addCategorie(null); } } return $this; } public function __toString(): string { return $this->nom ?? ''; } /** * @return Collection<int, TypeCollection> */ public function getTypeCollections(): Collection { return $this->typeCollections; } public function addTypeCollection(TypeCollection $typeCollection): self { if (!$this->typeCollections->contains($typeCollection)) { $this->typeCollections->add($typeCollection); $typeCollection->addCategory($this); } return $this; } public function removeTypeCollection(TypeCollection $typeCollection): self { if ($this->typeCollections->removeElement($typeCollection)) { $typeCollection->removeCategory($this); } return $this; }}