<?phpnamespace App\Entity;use App\Repository\CategoryCatalogueRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CategoryCatalogueRepository::class)]#[ORM\Table(name: 'CategoryCatalogue')]class CategoryCatalogue{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 255)] private ?string $libelle = null; #[ORM\Column(type: 'string', length: 100, nullable: true)] private ?string $code = null; /** * Relation ManyToMany avec CategorieMarche. * Une catégorie d'article peut correspondre à plusieurs catégories de marché * et un fournisseur peut appartenir à plusieurs catégories. * * Table pivot générée automatiquement : category_catalogue_categorie_marche */ #[ORM\ManyToMany(targetEntity: CategorieMarche::class)] #[ORM\JoinTable( name: 'category_catalogue_categorie_marche', joinColumns: [new ORM\JoinColumn(name: 'category_catalogue_id', referencedColumnName: 'id')], inverseJoinColumns: [new ORM\JoinColumn(name: 'categorie_marche_id', referencedColumnName: 'id')] )] private Collection $categoriesMarche; public function __construct() { $this->categoriesMarche = new ArrayCollection(); } // ====================== // GETTERS / SETTERS // ====================== public function getId(): ?int { return $this->id; } public function getLibelle(): ?string { return $this->libelle; } public function setLibelle(?string $libelle): self { $this->libelle = $libelle; return $this; } public function getCode(): ?string { return $this->code; } public function setCode(?string $code): self { $this->code = $code; return $this; } public function getCategoriesMarche(): Collection { return $this->categoriesMarche; } public function addCategorieMarche(CategorieMarche $categorieMarche): self { if (!$this->categoriesMarche->contains($categorieMarche)) { $this->categoriesMarche->add($categorieMarche); } return $this; } public function removeCategorieMarche(CategorieMarche $categorieMarche): self { $this->categoriesMarche->removeElement($categorieMarche); return $this; } public function hasCategorieMarche(CategorieMarche $categorieMarche): bool { return $this->categoriesMarche->contains($categorieMarche); } public function __toString(): string { return $this->libelle ?? ''; }}