<?phpnamespace App\Entity;use App\Repository\SousCategorieRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use phpDocumentor\Reflection\Types\Integer;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: SousCategorieRepository::class)]class SousCategorie{ //Déclarations des variables #[ORM\Id] #[ORM\Column(name: 'id_sous_categorie',type: 'integer', nullable: false)] //Spécifie que la valeur générée est un ID auto-incrémenté #[ORM\GeneratedValue(strategy:'IDENTITY')] private ?int $id; #[ORM\Column(length: 255, nullable: false)] private ?string $nom = null; //Associations #[ORM\ManyToOne(targetEntity: Categorie::class, inversedBy: 'sousCategories')] #[ORM\JoinColumn(referencedColumnName: 'id_categorie', nullable: false)] private ?Categorie $categorie = null; //Association bidirectionnelle #[ORM\ManyToMany(targetEntity: Model::class, mappedBy:'sousCategories')] private ?Collection $models; //Constructeur public function __construct() { $this->models = 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 Categorie|null */ public function getCategorie(): ?Categorie { return $this->categorie; } /** * @param Categorie|null $categorie */ public function setCategorie(?Categorie $categorie): void { $this->categorie = $categorie; } //Fonctions des collections /** * @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->addSousCategorie($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->getSousCategories() === $this) { $model->addSousCategorie(null); } } return $this; }// public function __toString(): string// {// return $this->nom ?? '';// }}