src/Entity/CategoryCatalogue.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryCatalogueRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: CategoryCatalogueRepository::class)]
  8. #[ORM\Table(name: 'CategoryCatalogue')]
  9. class CategoryCatalogue
  10. {
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue]
  13. #[ORM\Column(type: 'integer')]
  14. private ?int $id = null;
  15. #[ORM\Column(type: 'string', length: 255)]
  16. private ?string $libelle = null;
  17. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  18. private ?string $code = null;
  19. /**
  20. * Relation ManyToMany avec CategorieMarche.
  21. * Une catégorie d'article peut correspondre à plusieurs catégories de marché
  22. * et un fournisseur peut appartenir à plusieurs catégories.
  23. *
  24. * Table pivot générée automatiquement : category_catalogue_categorie_marche
  25. */
  26. #[ORM\ManyToMany(targetEntity: CategorieMarche::class)]
  27. #[ORM\JoinTable(
  28. name: 'category_catalogue_categorie_marche',
  29. joinColumns: [new ORM\JoinColumn(name: 'category_catalogue_id', referencedColumnName: 'id')],
  30. inverseJoinColumns: [new ORM\JoinColumn(name: 'categorie_marche_id', referencedColumnName: 'id')]
  31. )]
  32. private Collection $categoriesMarche;
  33. public function __construct()
  34. {
  35. $this->categoriesMarche = new ArrayCollection();
  36. }
  37. // ======================
  38. // GETTERS / SETTERS
  39. // ======================
  40. public function getId(): ?int
  41. {
  42. return $this->id;
  43. }
  44. public function getLibelle(): ?string
  45. {
  46. return $this->libelle;
  47. }
  48. public function setLibelle(?string $libelle): self
  49. {
  50. $this->libelle = $libelle;
  51. return $this;
  52. }
  53. public function getCode(): ?string
  54. {
  55. return $this->code;
  56. }
  57. public function setCode(?string $code): self
  58. {
  59. $this->code = $code;
  60. return $this;
  61. }
  62. public function getCategoriesMarche(): Collection
  63. {
  64. return $this->categoriesMarche;
  65. }
  66. public function addCategorieMarche(CategorieMarche $categorieMarche): self
  67. {
  68. if (!$this->categoriesMarche->contains($categorieMarche)) {
  69. $this->categoriesMarche->add($categorieMarche);
  70. }
  71. return $this;
  72. }
  73. public function removeCategorieMarche(CategorieMarche $categorieMarche): self
  74. {
  75. $this->categoriesMarche->removeElement($categorieMarche);
  76. return $this;
  77. }
  78. public function hasCategorieMarche(CategorieMarche $categorieMarche): bool
  79. {
  80. return $this->categoriesMarche->contains($categorieMarche);
  81. }
  82. public function __toString(): string
  83. {
  84. return $this->libelle ?? '';
  85. }
  86. }